[Python-Dev] unicode/string asymmetries

Martin v. Loewis martin@v.loewis.de
Thu, 10 Jan 2002 01:18:09 +0100


>    This could be a problem with my file patches as I have been using
> PyUnicode_AS_UNICODE which will 4 byte strings if Py_UNICODE_WIDE is
> defined. 4 byte strings can not be passed to the Windows API. So it looks
> like PyUnicode_AsWideChar has to be used instead with a wrapper to allocate
> enough memory to hold the resulting string.

Yes. Unfortunately, that would be much more inefficient. So I'd
suggest you just put an assertion into the code that Py_UNICODE is the
same size as WCHAR (that can be even done through a preprocessor
#error, using the _SIZE #defines). I'll expect people will resist
changing Py_UNICODE on Windows for quite some time, even if other
platforms move on.

Regards,
Martin