问题
My batch file started to write output to log file in Chinese. Code:
echo ============= >> D:\path\file.log
echo. >> D:\path\file.log
echo. >> D:\path\file.log
echo Import new data to table %date% D:\path\file.log
sqlcmd -S (local)\sqlexpress -E -d DB_Name -Q "exit(exec[dbo].[StoredProcedure])" >> D:\path\file.log
It worked fine for many months and all of a sudden it started to write the whole output in weird format like here:
㴽㴽㴽㴽㴽㴽‽ഠ 浉潰瑲渠睥搠瑡潴匠䍒剟䵅䑅彙䅒⁗慴汢㤰〯⼲〲㘱ഠ 㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽㴽ഠ刊浥摥⁹慄慴䰠湡楤杮娠湯㩥㐨㌶㔰爠睯晡敦瑣摥ഩ
I saw this related question but it refers to a specific command issue as far as I understand. I would appreciate your help.
EDIT: After creating the batch file from scratch, the problem disappeared. Still don;t know what was the issue.
回答1:
Please Change your Language Via Below Command and Write log again after that check your logs.
EXEC sp_configure 'default language', 23
RECONFIGURE
回答2:
In my case resolution was simply recreating both the batch file and the log file. Make sure you save the files in correct encoding format too.
EDIT: After some more investigation I found out that script clearing the log file (deleting some lines) that I used once must have changed the encoding to UCS-2 Little Endian.
来源:https://stackoverflow.com/questions/35287761/cmd-exe-output-in-chinese