简体   繁体   中英

Unicode on Windows Changing the console font

I am outputting unicode characters to the console on Windows and the output is as expected when I manually change the font to Lucidia Grande. But my question is, how can Python, Ruby etc ... output unicode characters to the Windows console using the default font? I thought the default font didn't support all of the unicode characters?

how can Python, Ruby etc ... output unicode characters to the Windows console using the default font?

They can't and don't display all Unicode characters. The default console font aka “Raster Fonts” maps to a .fon file with glyphs for the characters in your locale's DOS code page. For Western European installs that is code page 850 . You do get some accented letters and other non-ASCII characters in this code page, but anything else from wider Unicode will be displayed as ? .

In reality even if you change to a vector font you are still limited to a single code page when you run programs that use the MS C runtime's implementation of the standard library I/O functions (which Python and Ruby do). You get more of a choice in that you can use chcp to change to a wider range of code pages than “Raster Fonts” has support for, but you still can't get all of Unicode this way.

(In principle you should be able to chcp 65001 to get UTF-8, but there are serious bugs in the Windows implementation of this that usually make it unusable. Or chcp 65000 for UTF-16, but as that's not an ASCII superset it tends to break stdio apps including Python/Java etc.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM