Cmd.exe输出中文 [英] Cmd.exe output in Chinese

查看:129
本文介绍了Cmd.exe输出中文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的批处理文件开始用中文将输出写入日志文件. 代码:

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.

从头开始创建批处理文件后,问题消失了.还是不知道是什么问题.

After creating the batch file from scratch, the problem disappeared. Still don;t know what was the issue.

推荐答案

就我而言,解决方案只是重新创建批处理文件和日志文件.确保您也以正确的编码格式保存文件.

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.

经过更多调查后,我发现清除曾经使用过的日志文件(删除一些行)的脚本必须将编码更改为UCS-2 Little Endian.

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.

这篇关于Cmd.exe输出中文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆