Unicode style in win32/PythonWin
theller at python.net
Thu Jan 12 10:33:48 CET 2006
"Robert" <kxroberto at googlemail.com> writes:
> Neil Hodgson wrote:
>> > 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.
>> 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
FYI, if you assign the argtypes attribute for ctypes functions, the
ascii/unicode conversion is automatic (if needed).
So after these assignments:
ctypes.windll.user32.MessageBoxW.argtypes = (c_int, c_wchar_p,
ctypes.windll.user32.MessageBoxA.argtypes = (c_int, c_char_p,
both MessageBoxA and MessageBoxW can both be called with either ansi and
unicode strings, and should work correctly. By default the conversion
is done with ('msbc', 'ignore'), but this can also be changed,
ctypes-wide, with a call to ctypes.set_conversion_mode(encoding,errors).
You have to pass None for the third parameter (if not a string).
More information about the Python-list