Unicode style in win32/PythonWin

Robert kxroberto at googlemail.com
Thu Jan 12 03:35:46 EST 2006

Neil Hodgson wrote:
> Robert:
> > After "is_platform_unicode = <auto>", scintilla displays some unicode
> > as you showed. but the win32-functions (e.g. MessageBox) still do not
> > pass through wide unicode.
>     Win32 issues are better discussed on the python-win32 mailing list
> which is read by more of the people interested in working on this library.
> http://mail.python.org/mailman/listinfo/python-win32
>     Patches that improve MessageBox in particular or larger sets of
> functions in a general way are likely to be welcomed.

ok. I have no patches so far as of now - maybe later. Played with
Heller's ctypes for my urgent needs. That works correct with unicode
like this:

>>> import ctypes
>>> ctypes.windll.user32.MessageBoxW(0,u'\u041f\u043e\u0448\u0443\u043a.txt',0,0)

My recommendation for the general style of unicode integration in win32
in future:
* output-functions should dispatch auto on unicode paramams in order to
use the apropriate xxxW-functions
* input-functions (which are used much more infrequent in apps!) should
accept an additional unicode=1 parameter (e.g.:
SetWindowText(unicode=1);  please not extra xxxW -functions! thus one
can easily virtualize apps with something like
* or: input-functions should also auto-run unicode when a significant
string calling parameter is unicode - same as with filesystem-functions
in normal python. Example: win32api.FindFiles(u"*")  is same as
FindFiles("*",unicode=1) and is better as FindFilesW("*")

Thus existing ansi apps can be converted to unicode aware apps with
minimum extra efforts.


More information about the Python-list mailing list