CMD 输出文本文件包含亚洲符号

时间:2021-05-11 11:20:27

标签: file text cmd output

我有 CMD 输出文本文件的问题。 文本文件里面是中文符号,而不是简单的短信。

命令:

::this will check if is PC online.
set LOCALV_WORKSTATIONUP=0
( wmic /FAILFAST:ON /user: "admin" /password:"123456" /node:"Workstation1.subdomain.domain" computersystem get "Name"  >>Check.txt ) && set LOCALV_WORKSTATIONUP=1

::this will execute something while PC is online. And this is also problematic part.
IF "!LOCALV_WORKSTATIONUP!" == "1" (echo "It's working." >> Check.txt) ELSE (echo "It's NOT working." >> Check.txt)

输出文本文件 Check.txt 包含:

Workstation1  
䤢❴⁳低⁔潷歲湩⹧•਍

代替:

Workstation1  
It's working.

Screenshot of CMD + output text file

  • 我不在任何 PC 上使用任何亚洲语言。
  • 我在两台使用英语和斯洛伐克语的 PC 上进行了尝试。
  • 而且我还尝试在 CMD 中将 chcp 更改为 850852437650011250,但没有更改。符号没有改变。
  • 我试过|more>> Check.txt

一切都没有成功。

如何以请求的格式获取输出文本文件?

1 个答案:

答案 0 :(得分:0)

尝试使用

Console.OutputEncoding = Encoding.GetEncoding(936);

在从源到目的地的旅程的某个时刻,您的 unicode 字符串已经通过一些不理解 unicode 的东西。

相关问题