Cmd.exe output in Chinese

和自甴很熟 提交于 2019-12-12 02:27:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!