cmd以某种方式将中文文本作为输出 [英] cmd is somehow writing Chinese text as output

查看:22
本文介绍了cmd以某种方式将中文文本作为输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 cmd.exe 时遇到了一些问题.我有时使用它来创建文件并在那里写入输出.但如果我试试这个:

I have some trouble with cmd.exe. I use it sometimes to create files and write there the output. But if I try this:

wmic logicaldisk get name, freespace >> output.txt
echo %date% >> output.txt

然后我启动它两到三次,我得到一个 output.txt 像:

And I start it two to three times, I get an output.txt like:

FreeSpace    Name  
17990881280  C:    
             D:    
㠱〮⸴〲㈱ഠ䘊爀攀攀匀瀀愀挀攀    一愀洀攀  ഀ਀㄀㜀㤀㤀 㠀㠀㄀㈀㠀   䌀㨀    ഀ਀             䐀㨀    ഀ਀㄀⸸㐰㈮㄰′਍

嗯,那里的中文文字看起来很有趣,但我想看看日期.我认为以某种方式编码随日期改变.一切都很好,如果我执行 echo %date% >>output.txt 单独.

Well, the Chinese text there looks funny, but I would like to see the date. I think somehow the encoding is changed with date. Everything is fine and I get the date if I do echo %date% >> output.txt alone.

我想获得 wmic 输出和日期.

I would like to get the wmic output and the date.

我该怎么办?

推荐答案

WMIC 有一些奇怪的输出.我看过一个讨论,说 WMIC 使用 unicode,但我认为情况比这更复杂.如果我将 WMIC 输出捕获到文件并使用十六进制编辑器,我会在每行末尾看到一个额外的回车符.当输入 output.txt 时,我完全不知道如何将日期内容转换为乱码.(代码页问题?但怎么办?)在我的机器上,我在日期应该在哪里得到问号.

WMIC has some weird output. I've seen a discussion where it was said WMIC uses unicode, but I think the situation is more complicated than that. If I capture WMIC output to a file and use a hex editor, I see an extra carriage return at the end of each line. I am completely at a loss as to how the date content is converted into gibberish when the output.txt is typed. (codepage issue? but how?) On my machine I get question marks where the date should be.

我能够通过使用来解决问题

I was able to fix the problem by using

wmic logicaldisk get name, freespace | more >>output.txt
echo %date%>>output.txt 

这篇关于cmd以某种方式将中文文本作为输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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