windows 如何在windows下的cmd窗口中显示日语汉字?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3780378/
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
How to display japanese Kanji inside a cmd window under windows?
提问by jdehaan
I have an english Windows 2003 server with asiatic language support activated. The two only fonts available for the command window (cmd settings) are raster and lucida console. Neither the one nor the other display the Kanji correctly (displayed as question mark).
我有一个启用了亚洲语言支持的英文 Windows 2003 服务器。可用于命令窗口(cmd 设置)的两种唯一字体是 raster 和 lucida 控制台。一个和另一个都不能正确显示汉字(显示为问号)。
Is there a solution to get them displayed? Is there some transformation I must do in my application before writing out to the console?
有没有办法让它们显示出来?在写到控制台之前,我必须在我的应用程序中进行一些转换吗?
I am writing UTF8 out at the moment, what works well also for some non ASCII characters (like ??ü?). The source code writing to the console has the correct data (the Kanji can be viewed in the debugger correctly). If it matters, I am writing the app in C#.
我现在正在写 UTF8,对于一些非 ASCII 字符(比如 ??ü?),什么也能很好地工作。写入控制台的源代码具有正确的数据(可以在调试器中正确查看汉字)。如果重要的话,我正在用 C# 编写应用程序。
EDIT: I found this linkwhich explains the issues behind the problem and presents a solution (involving native calls) for C#. This shall work well with .NET 4.5 (untested by me)
编辑:我发现这个链接解释了问题背后的问题,并为 C# 提供了一个解决方案(涉及本机调用)。这将适用于 .NET 4.5(未经我测试)
采纳答案by paludarium
If you find a font that will display the Kanji character set, you can add that font to the cmd Settings by adding values under this Registry key:
如果您找到将显示汉字字符集的字体,您可以通过在此注册表项下添加值来将该字体添加到 cmd 设置:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont\
Values:
价值观:
Name: 00
Data: Consolas
I've done this before but found this reference on SuperUser: https://superuser.com/q/55318
我以前做过这个,但在 SuperUser 上找到了这个参考:https: //superuser.com/q/55318
Hope this helps
希望这可以帮助
回答by bobince
How is your application writing output? The C byte-based stdio calls like printf
won't support UTF-8 on Windows unless you have specifically set the console to use UTF-8 encoding by saying chcp 65001 && somecommand
(and even then there are problems).
您的应用程序编写输出如何?基于 C 字节的 stdio 调用printf
不会在 Windows 上支持 UTF-8,除非您通过说chcp 65001 && somecommand
(即使这样也有问题)专门将控制台设置为使用 UTF-8 编码。
Without chcp
, the console will be using the Windows installation's default code page, in this case cp1252, and writing in kanji will be impossible even if the console font you're using has glyphs for it.
如果没有chcp
,控制台将使用 Windows 安装的默认代码页,在本例中为 cp1252,即使您使用的控制台字体具有字形,也无法使用汉字书写。
If you want to write Unicode to the console reliably you would have to use character-based interfaces like wprintf
.
如果您想将 Unicode 可靠地写入控制台,则必须使用基于字符的接口,如wprintf
.
回答by crusherjoe
This is how I can got Chinese input/output in cmd.exe running on Windows 7 Pro English Version.
这就是我如何在 Windows 7 Pro 英文版上运行的 cmd.exe 中获得中文输入/输出。
Install console2,which is a front-end to cmd.exe (and other shells).
After installation, follow the instruction here
- Delete key "Console2 command window" in registry
Import the following data into windows registry:
For Chinese(中文) Windows XP & Vista:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Console\Console2 command window] "CodePage"=dword:000003a8 "FontSize"=dword:000a0000 "FontFamily"=dword:00000036 "FontWeight"=dword:00000190 "FaceName"="細明體" "HistoryNoDup"=dword:00000000
For Japanese(日本語) Windows XP & Vista:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Console\Console2 command window] "CodePage"=dword:000003a8 "FontSize"=dword:000a0000 "FontFamily"=dword:00000036 "FontWeight"=dword:00000190 "FaceName"="MS 明朝" "HistoryNoDup"=dword:00000000
You may or may not have to change the font. Initially I had the font set to @NimSum, and the Chinese characters came out rotate 90 degrees. Then I switched to NimSum (without the @) and it came out correctly. Then just out of curiosity I switched to Consola and yet I can still see the Chinese Characters. So not sure if you actually have to set the font or not.
安装console2,它是 cmd.exe(和其他 shell)的前端。
安装后,请按照此处的说明进行操作
- 删除注册表中的“Console2 命令窗口”项
将以下数据导入 Windows 注册表:
对于中文(中文)Windows XP & Vista:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Console\Console2 command window] "CodePage"=dword:000003a8 "FontSize"=dword:000a0000 "FontFamily"=dword:00000036 "FontWeight"=dword:00000190 "FaceName"="細明體" "HistoryNoDup"=dword:00000000
对于日语(日本语)Windows XP 和 Vista:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Console\Console2 command window] "CodePage"=dword:000003a8 "FontSize"=dword:000a0000 "FontFamily"=dword:00000036 "FontWeight"=dword:00000190 "FaceName"="MS 明朝" "HistoryNoDup"=dword:00000000
您可能需要也可能不需要更改字体。最初我将字体设置为@NimSum,然后汉字旋转90度就出来了。然后我切换到 NimSum(没有@),结果正确。然后出于好奇,我切换到Consola,但我仍然可以看到汉字。所以不确定你是否真的需要设置字体。