> 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\u043
> a.txt',0,0)
> 1

In general, the "ascii" win32 functions will actually take MBCS encoded
strings.  So:

>>> import win32api
>>> win32api.MessageBox(0, u"Here is a \xa9 symbol".encode("mbcs"), "title",
0)

Displays a message box with a copyright symbol.  You should find this true
for pretty much all win32 functions.  Many functions will actually still
allow you to specify a unicode string directly and automatically convert to
MBCS, but MessageBox doesn't get this behaviour as it still uses
PyArg_ParseTuple with the 's' format char.  (Not surprisingly, MessageBox
was one of the very first functions added to win32api, which was the very
first win32 module :)

This only falls apart when you need to represent a unicode character not in
the user's codepage, but that is rare.

As you mention, the correct thing for this function to do is automatically
use the W function when either of the string args are unicode - as usual,
patches gratefully accepted :)

Cheers,

Mark

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to