Unicode & Pythonwin / win32 / console?

Robert kxroberto at googlemail.com
Tue Jan 10 04:40:01 EST 2006


Martin v. Löwis schrieb:

> Robert wrote:
> > I'm using Pythonwin and py2.3 (py2.4).  I did not come clear with this:
> > I want to use win32-fuctions like win32ui.MessageBox,
> > listctrl.InsertItem ..... to get unicode strings on the screen - best
> > results according to the platform/language settings (mainly XP Home,
> > W2K, ...).
>
> Not sure what your question is - is there even a question in this
> paragraph? (notice I didn't understand the term "to come clear with")
>
> > 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.

hmm...? never got any non-questionable results:

PythonWin 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit
(Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond (mhammond at skippinet.com.au) -
see 'Help/About PythonWin' for further copyright information.
>>> import win32ui,glob
>>> s=glob.glob(u'/devel/test/*')[-2]
>>> s
u'/devel/test\\\u041f\u043e\u0448\u0443\u043a.txt'
>>> 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)
>>> print s
/devel/test\?????.txt
>>>

[on a WinXP Home - German; same with py2.3, win98, ... ]
The Windows Explorer displays correct cyrillic letters for this file
name.
win32ui.MessageBox(s) seems to try ascii codec by default. But
mbcs/latin-1 (?) encoded 8bit strings like  'aousäöüß'   (
=='aous\\xe4\\xf6\\xfc\\xdf' ) work (on this machine).

Robert




More information about the Python-list mailing list