unable to print Unicode characters in Python 3

Benjamin Kaplan benjamin.kaplan at case.edu
Wed Jan 28 04:13:49 CET 2009


On Tue, Jan 27, 2009 at 9:16 PM, Gabriel Genellina
<gagsl-py2 at yahoo.com.ar>wrote:

> En Wed, 28 Jan 2009 00:03:55 -0200, John Machin <sjmachin at lexicon.net>
> escribió:
>
>  On Jan 28, 5:56 am, "Martin v. Löwis" <mar... at v.loewis.de> wrote:
>>
>>> > #include "stdio.h"
>>> > int main(int argc, char **argv) {
>>> >     printf("<\xc2\x80>\n");
>>> >     }
>>>
>>> > compiled with mingw32 (gcc (GCC) 3.4.5 (mingw-vista special r3))
>>> > and using "Lucida Console" font:
>>>
>>> > After CHCP 1252, this prints < A-circumflex Euro >, as expected.
>>> > After CHCP 65001, it prints < hollow-square >.
>>>
>>> This is not surprising: this character is U+0080, which is a control
>>> character. Try \xe2\x82\xac instead.
>>>
>>
>> Doh! I'm a nutter. That works. Thanks. The only font choice offered
>> apart from "Raster Fonts" in the Command Prompt window's Properties
>> box is "Lucida Console", not "Lucida Sans Unicode". It will let me
>> print Cyrillic characters from a C program, but not Chinese. I'm off
>> looking for how to get a better font.
>>
>
> In this post, Raymond Chen explains all the conditions a font must met to
> actually be usable in a console window:
> http://blogs.msdn.com/oldnewthing/archive/2007/05/16/2659903.aspx
> In short, most TrueType font's (even the fixed-width ones) aren't eligible.
>

Actually, you can trick the command prompt into allowing any TrueType font,
if you don't mind messing with the registry. The font won't look so good,
but it will still work. Even with a font that supports Unicode (GNU
FreeMono), the console still displays 3 unprintable characters rather than
the single multi-byte character.

>
> --
> Gabriel Genellina
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090127/a831095c/attachment.html>


More information about the Python-list mailing list