[Part]fix makeWireString for Win & Py > 3.09

This commit is contained in:
wandererfan
2022-08-29 12:16:21 -04:00
committed by WandererFan
parent 3362e64adc
commit 8887890bf9

View File

@@ -2028,8 +2028,15 @@ private:
pysize = PyUnicode_GetLength(p);
#if PY_VERSION_HEX < 0x03090000
unichars = PyUnicode_AS_UNICODE(p);
#else
#ifdef FC_OS_WIN32
//PyUNICODE is only 16 bits on Windows (wchar_t), so passing 32 bit UCS4
//will result in unknow glyph in even positions, and wrong characters in
//odd positions.
unichars = (Py_UNICODE*)PyUnicode_AsWideCharString(p, &pysize);
#else
unichars = (Py_UNICODE *)PyUnicode_AsUCS4Copy(p);
#endif
#endif
}
else if (PyUnicode_Check(intext)) {
@@ -2037,8 +2044,15 @@ private:
#if PY_VERSION_HEX < 0x03090000
unichars = PyUnicode_AS_UNICODE(intext);
#else
#ifdef FC_OS_WIN32
//PyUNICODE is only 16 bits on Windows (wchar_t), so passing 32 bit UCS4
//will result in unknow glyph in even positions, and wrong characters in
//odd positions.
unichars = (Py_UNICODE*)PyUnicode_AsWideCharString(intext, &pysize);
#else
unichars = (Py_UNICODE *)PyUnicode_AsUCS4Copy(intext);
#endif
#endif
}
else {