[issue10653] test_time test_strptime fails on windows

Hirokazu Yamamoto report at bugs.python.org
Wed Dec 8 18:46:29 CET 2010


Hirokazu Yamamoto <ocean-city at m2.ccsnet.ne.jp> added the comment:

I think this is locale problem. With "C" locale on windows,
wcsftime doesn't return UTF16. (when non ascii characters
are contained)

It is just like ....
char cbuf[] = "...."; /* contains non ascii chars in MBCS */
wchar_t wbuf[sizeof(cbuf)];
for (size_t i = 0; i < sizeof(cbuf); ++i)
    wbuf[i] = cbuf[i];
/* just copy it. non ascii chars in MBCS uses two bytes,
   but should use 1 char space in UTF16. But this case,
   it uses 2 chars space! (something strange encoding) */

In japanese, wcsftime returns non ascii characters for
timezone in this strange encoding. Python converts this
with

#ifdef HAVE_WCSFTIME
            ret = PyUnicode_FromWideChar(outbuf, buflen);
#else

so Unicode object will contain data in this strange encoding.
This is cause of problem.

I investigated a little about locale, and I learned C
standard does not guarantee wchar_t is always UTF16.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10653>
_______________________________________


More information about the Python-bugs-list mailing list