|
|
|
@ -100,11 +100,13 @@ TQString PyString2TQString(PyObject* text)
|
|
|
|
|
}
|
|
|
|
|
else if (PyUnicode_CheckExact(text))
|
|
|
|
|
{
|
|
|
|
|
Py_UNICODE* t = PyUnicode_AsUnicode(text);
|
|
|
|
|
if(sizeof(Py_UNICODE) == 4)
|
|
|
|
|
qtext = fromUcs4((TQ_UINT32*)t);
|
|
|
|
|
else
|
|
|
|
|
qtext = TQString::fromUcs2((TQ_UINT16*)t);
|
|
|
|
|
int uniSize = PyUnicode_KIND(text);
|
|
|
|
|
if (uniSize == PyUnicode_4BYTE_KIND)
|
|
|
|
|
qtext = fromUcs4((TQ_UINT32*)PyUnicode_4BYTE_DATA(text));
|
|
|
|
|
else if (uniSize == PyUnicode_2BYTE_KIND)
|
|
|
|
|
qtext = TQString::fromUcs2((TQ_UINT16*)PyUnicode_2BYTE_DATA(text));
|
|
|
|
|
else if (uniSize == PyUnicode_1BYTE_KIND)
|
|
|
|
|
qtext.setAscii((char*)PyUnicode_1BYTE_DATA(text));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -119,34 +121,11 @@ PyObject* TQString2PyString(TQString string)
|
|
|
|
|
PyObject *pyString;
|
|
|
|
|
|
|
|
|
|
const unsigned short* tmp = string.ucs2();
|
|
|
|
|
bool dofree = false;
|
|
|
|
|
|
|
|
|
|
if(tmp)
|
|
|
|
|
{
|
|
|
|
|
#if Py_UNICODE_SIZE == 4
|
|
|
|
|
|
|
|
|
|
Py_UNICODE* buf = new Py_UNICODE[string.length()];
|
|
|
|
|
|
|
|
|
|
for(unsigned int i = 0; i < string.length(); i++)
|
|
|
|
|
{
|
|
|
|
|
buf[i] = tmp[i];
|
|
|
|
|
}
|
|
|
|
|
dofree = true;
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
Py_UNICODE* buf = (Py_UNICODE*) tmp;
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
pyString = PyUnicode_FromUnicode(buf, string.length());
|
|
|
|
|
|
|
|
|
|
if(dofree)
|
|
|
|
|
{
|
|
|
|
|
delete [] buf;
|
|
|
|
|
}
|
|
|
|
|
pyString = PyUnicode_FromKindAndData(PyUnicode_2BYTE_KIND, tmp, string.length());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
pyString = PyBytes_FromString("");
|
|
|
|
|
|
|
|
|
|