我们在Team Foundation Server (TFS)中有一个项目,其中有一个非英语字符(š)。当尝试编写一些与构建相关的脚本时,我们偶然发现了一个问题——我们不能将这个字母传递给命令行工具。命令提示符或其他东西会把它弄乱,tf.exe实用程序无法找到指定的项目。

我尝试了不同格式的.bat文件(ANSI, UTF-8,带BOM和不带BOM),以及用JavaScript编写脚本(本质上是Unicode) -但运气不好。如何执行程序并传递一个Unicode命令行?


当前回答

从2019年6月开始,使用Windows 10,你将不必更改代码页。

参见“介绍Windows终端”(来自Kayla Cinnamon)和Microsoft/Terminal。 通过使用Consolas字体,将提供部分Unicode支持。

如Microsoft/Terminal issue 387中所述:

There are 87,887 ideographs currently in Unicode. You need all of them too? We need a boundary, and characters beyond that boundary should be handled by font fallback / font linking / whatever. What Consolas should cover: Characters that used as symbols that used by modern OSS programs in CLI. These characters should follow Consolas' design and metrics, and properly aligned with existing Consolas characters. What Consolas should NOT cover: Characters and punctuation of scripts that beyond Latin, Greek and Cyrillic, especially characters need complex shaping (like Arabic). These characters should be handled with font fallback.

其他回答

从2019年6月开始,使用Windows 10,你将不必更改代码页。

参见“介绍Windows终端”(来自Kayla Cinnamon)和Microsoft/Terminal。 通过使用Consolas字体,将提供部分Unicode支持。

如Microsoft/Terminal issue 387中所述:

There are 87,887 ideographs currently in Unicode. You need all of them too? We need a boundary, and characters beyond that boundary should be handled by font fallback / font linking / whatever. What Consolas should cover: Characters that used as symbols that used by modern OSS programs in CLI. These characters should follow Consolas' design and metrics, and properly aligned with existing Consolas characters. What Consolas should NOT cover: Characters and punctuation of scripts that beyond Latin, Greek and Cyrillic, especially characters need complex shaping (like Arabic). These characters should be handled with font fallback.

我通过在批处理文件中使用它们的短名称(8点3)来删除以unicode命名的文件,从而避免了类似的问题。

短名称可以通过执行dir /x查看。显然,这只适用于已知的Unicode文件名。

把代码页改成1252对我有用。我遇到的问题是,Windows Server 2008上的DOS正在将符号double doller§转换为另一个符号。

在我的BCP声明^§中,我使用了CHCP 1252和它之前的一个帽。

对于类似的问题(我的问题是在命令提示符上显示来自MySQL的UTF-8字符),

我是这样解决的:

我把命令提示符的字体改成了Lucida Console。(此步骤必须与您的情况无关。它只与你在屏幕上看到的东西有关,而与角色本身无关)。 我把代码页改成了Windows-1253。您可以在命令提示符中通过“chcp 1253”执行此操作。它适用于我想要查看UTF-8的情况。

Try:

chcp 65001

这会将代码页更改为UTF-8。此外,还需要使用Lucida控制台字体。