Can I get Console to show Chinese?

孤者浪人 提交于 2021-02-07 11:54:53

问题


I've always wondered if it would be possible to show UTF8 or UTF16-Chinese text in a Console window, e.g., Console.WriteLine(chinese). For the time being, it shows up as ???. Is it possible to kick up a Console session that supports Chinese characters?


回答1:


urxvt, the Unicode rxvt, is a Xwindow "console" that will show Chinese characters. Assuming you're using Windows, this can work under Cygwin or coLinux.

also see Unicode characters in Windows command line - how?. I haven't yet figured out how to change the font to Lucida, but at least chcp 65001 got rid of the question marks.

changing console font looks complicated: https://superuser.com/questions/5035/how-to-change-the-windows-console-font. (update: switched to Lucida by right-clicking on the console icon from within the Windows console; selecting Properties; the Font tab; and selected Lucida. no help, the Chinese characters show as blocks).

This: http://www.vistax64.com/powershell/239480-display-unicode-utf-8-files-windows-console.html, mentions Powershell ISE and Console2 (http://www.ghacks.net/2008/06/09/console-2-a-better-cmdexe/) as being able to display Chinese characters.




回答2:


Under cygwin, the following settings can enable English interface, yet supports Chinese character display from cat, tail, etc.

export LANG=en_US.UTF-8

export LC_CTYPE=zh_CN




回答3:


Go to Control Panel -> Region and Language -> Administrative -> Change system locale... and select a Chinese locale. Reboot and now your console windows will be codepage 936 and the font will be a font that can display Chinese characters.

You'll notice that a dir command can now display Chinese characters and if your programs write Unicode Chinese characters to the console, it displays properly (instead of little boxes).

This worked for me on Windows 7, with no need for language packs or special versions of Windows.



来源:https://stackoverflow.com/questions/6405428/can-i-get-console-to-show-chinese

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!