Unicode & Pythonwin / win32 / console?

"Martin v. Löwis" martin at v.loewis.de
Tue Jan 10 21:55:26 CET 2006


Robert wrote:
>>>Also unicode strings should be displayed as nice as possible at the
>>>console with normal print-s to stdout (on varying platforms, different
>>>windows/countries and linux, ...; I py2exe/cxfreeze apps) ...
>>>
>>>Any hints how to do this and make it as complete and automated as
>>>possible?
>>
>>No need to do anything - it should work out of the box.
[...]
>>>>win32ui.MessageBox(s)
> 
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 12-16: ordinal not in range(128)

Can't comment on that - this is a PythonWin issue.

>>>>print s
> 
> /devel/test\?????.txt
> 

I see. You need to do "chcp 1251" in your console first, for this
to print this string correctly (and potentially also set the
console font to Lucida Console).

However, if you would do the same on a Russian Windows installation,
the user will not need to change anything - cyrillic letters come
out right. Likewise for Umlauts in a German windows installation,
and Greek letters in a Greek installation.

Regards,
Martin



More information about the Python-list mailing list