如何在Windows命令行中使用Unicode字符?

本文翻译自: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: 我这样解决了:

  1. 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). (此步骤必须与您的情况无关。它仅与您在屏幕上看到的内容有关,而与角色的真实情况无关)。

  2. 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控制台中遇到俄语问题,则应在此处设置俄语:

更改非Unicode程序的语言


#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和瓶盖。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值