|
|
@ -49,14 +49,18 @@ plString PyString_AsStringEx(PyObject* obj) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (PyString_Check(obj)) |
|
|
|
if (PyString_Check(obj)) |
|
|
|
return plString::FromUtf8(PyString_AsString(obj)); |
|
|
|
return plString::FromUtf8(PyString_AsString(obj)); |
|
|
|
else if (PyUnicode_Check(obj)) |
|
|
|
|
|
|
|
{ |
|
|
|
if (PyUnicode_Check(obj)) { |
|
|
|
PyObject* utf8 = PyUnicode_AsUTF8String(obj); |
|
|
|
#if (Py_UNICODE_SIZE == 2) |
|
|
|
plString str = plString::FromUtf8(PyString_AsString(utf8)); |
|
|
|
return plString::FromUtf16(reinterpret_cast<const uint16_t *>(PyUnicode_AsUnicode(obj))); |
|
|
|
Py_DECREF(utf8); |
|
|
|
#elif (Py_UNICODE_SIZE == 4) |
|
|
|
return str; |
|
|
|
return plString::FromUtf32(reinterpret_cast<const UniChar *>(PyUnicode_AsUnicode(obj))); |
|
|
|
} else |
|
|
|
#else |
|
|
|
return plString::Null; |
|
|
|
# error "Py_UNICODE is an unexpected size" |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return plString::Null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool PyString_CheckEx(PyObject* obj) |
|
|
|
bool PyString_CheckEx(PyObject* obj) |
|
|
|