本文翻译自:How to use unicode characters in Windows command line?
We have a project in Team Foundation Server (TFS) that has a non-English character (š) in it. 我们在Team Foundation Server(TFS)中有一个项目,其中包含非英语字符(š)。 When trying to script a few build-related things we've stumbled upon a problem - we can't pass the š letter to the command-line tools. 当尝试编写一些与构建相关的东西的脚本时,我们偶然发现了一个问题-我们无法将š字母传递给命令行工具。 The command prompt or what not else messes it up, and the tf.exe utility can't find the specified project. 命令提示符或其他原因将其弄乱了,并且tf.exe实用程序找不到指定的项目。
I've tried different formats for the .bat file (ANSI, UTF-8 with and without BOM ) as well as scripting it in JavaScript (which is Unicode inherently) - but no luck. 我已经尝试过.bat文件的不同格式(ANSI,带有和不带有BOM的 UTF-8)以及在JavaScript中编写脚本的脚本(本质上是Unicode)-但没有运气。 How do I execute a program and pass it a Unicode command line? 如何执行程序并将其传递给Unicode命令行?
#1楼
参考:https://stackoom.com/question/1d3y/如何在Windows命令行中使用Unicode字符
#2楼
For a similar problem, (my problem was to show UTF-8 characters from MySQL on a command prompt), 对于类似的问题,(我的问题是在命令提示符下显示来自MySQL的UTF-8字符),
I solved it like this: 我这样解决了:
I changed the font of command prompt to Lucida Console. 我将命令提示符的字体更改为Lucida Console。 (This step must be irrelevant for your situation. It has to do only with what you see on the screen and not with what is really the character). (此步骤必须与您的情况无关。它仅与您在屏幕上看到的内容有关,而与角色的真实情况无关)。
I changed the codepage to Windows-1253. 我将代码页更改为Windows-1253。 You do this on the command prompt by "chcp 1253". 您可以通过“ chcp 1253”在命令提示符下执行此操作。 It worked for my case where I wanted to see UTF-8. 它适用于我想看UTF-8的情况。
#3楼
Check the language for non-Unicode programs. 检查非Unicode程序的语言。 If you have problems with Russian in the Windows console, then you should set Russian here: 如果您在Windows控制台中遇到俄语问题,则应在此处设置俄语:
#4楼
A better cleaner thing to do: Just install the available, free, Microsoft Japanese language pack. 更好的清洁方法是:只需安装可用的免费Microsoft日语语言包。 (Other oriental language packs will also work, but I have tested the Japanese one.) (其他东方语言包也可以使用,但我已经测试了日语。)
This gives you the fonts with the larger sets of glyphs, makes them the default behavior, changes the various Windows tools like cmd, WordPad, etc. 这为您提供了带有较大字形集的字体,使它们成为默认行为,并更改了各种Windows工具(如cmd,写字板等)。
#5楼
To utf-8: chcp 65001
到utf-8: chcp 65001
Back to default: chcp 437
返回默认值: chcp 437
#6楼
Changing code page to 1252 is working for me. 将代码页更改为1252对我有用。 The problem for me is the symbol double doller § is converting to another symbol by DOS on Windows Server 2008. 对我来说,问题是符号double doller§正在Windows Server 2008上由DOS转换为另一个符号。
I have used CHCP 1252 and a cap before it in my BCP statement ^§. 我在BCP语句^§中使用过CHCP 1252和瓶盖。