问题
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