Windows 7 CMD 中的 UTF-8
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19955385/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UTF-8 in Windows 7 CMD
提问by strudelkopf
I've tried to display UTF-8 in the win7 cmd. Currently, I'm using the standard font because as I see with the mysql.exe, it works fine with the characters I'm working with (currently the german umlauts "???ü??ü"). Also, with another font, the same characters appear.
我试图在 win7 cmd 中显示 UTF-8。目前,我正在使用标准字体,因为正如我在 mysql.exe 中看到的那样,它可以很好地处理我正在使用的字符(目前是德国变音符号“???ü??ü”)。此外,使用另一种字体时,会出现相同的字符。
But the output of my PHP script displays garbage, e.g. '??' for '?'. When I pipe the output into a file and open it up with Notepad++, it says the encoding is UTF-8. In php.ini I set UTF-8 as the encoding as well as in the connection to the mySQL database, and in the database itself UTF-8, too.
但是我的 PHP 脚本的输出显示垃圾,例如 '??' 为了 '?'。当我将输出通过管道传输到一个文件中并用 Notepad++ 打开它时,它说编码是 UTF-8。在 php.ini 中,我将 UTF-8 设置为编码以及与 mySQL 数据库的连接,以及数据库本身的 UTF-8。
In CMD I tried so far to set the code page to 65001, but nothing changes.
在 CMD 中,我尝试将代码页设置为 65001,但没有任何变化。
edit: my PHP script is saved as UTF-8 as well
编辑:我的 PHP 脚本也保存为 UTF-8
It seems with latin1, my desired characters can be displayed too and actually it works. But there has to be a way to do it in UTF-8? I can't convert everything to latin1
似乎在 latin1 中,我想要的字符也可以显示,实际上它可以工作。但是必须有一种方法可以在 UTF-8 中做到这一点吗?我无法将所有内容转换为 latin1
采纳答案by Sergey Vlasov
This question has been already answered in Unicode characters in Windows command line - how?
这个问题已经在 Windows 命令行中的Unicode 字符中得到了回答- 如何?
You missed one step -> you need to use Lucida console fonts in addition to executing chcp 65001 from cmd console.
您错过了一个步骤 -> 除了从 cmd 控制台执行 chcp 65001 之外,您还需要使用 Lucida 控制台字体。