unicode printing on Windows

Andrew Berg bahamutzero8825 at gmail.com
Thu Feb 9 12:19:10 CET 2012


On 2/9/2012 4:46 AM, BlueBird wrote:
> Does anybody know how to fix problem 1 ? That way, I could at least
> deal with programs that print UTF8 on stdout.
I'm pretty sure there isn't a way. cp65001 is supposed to be UTF-8, but
it doesn't work in my experience (I fed it some UTF-8 demo text and I
got garbage and beeping). Python 3.3 will support cp65001, 3.2 and below
do not.

> Regarding point 2, I must admit even when I am the author of the
> program, printing debug information (in unicode) on the stdout is a
> really really tricky thing. Is there a recommendation on how to do
> that properly ?
Use the logging module, perhaps? It has handled encoding issues
automatically, at least in my experience. In Python 3, you can convert a
string to bytes from one encoding, then convert to another encoding, but
Python 2 has things set up very differently (and my experience is with
py3k, so I can't help much).

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640



More information about the Python-list mailing list