mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
dtoolutil: minor fix to TextEncoder::append_text
This commit is contained in:
parent
2d80d6d063
commit
d7f19b73e0
@ -94,7 +94,12 @@ append_text(PyObject *text) {
|
||||
#if PY_VERSION_HEX >= 0x03030000
|
||||
Py_ssize_t len;
|
||||
const char *str = PyUnicode_AsUTF8AndSize(text, &len);
|
||||
_this->append_text(std::string(str, len));
|
||||
std::string text_str(str, len);
|
||||
if (_this->get_encoding() == TextEncoder::E_utf8) {
|
||||
_this->append_text(text_str);
|
||||
} else {
|
||||
_this->append_wtext(TextEncoder::decode_text(text_str, TextEncoder::E_utf8));
|
||||
}
|
||||
#else
|
||||
Py_ssize_t len = PyUnicode_GET_SIZE(text);
|
||||
wchar_t *str = (wchar_t *)alloca(sizeof(wchar_t) * (len + 1));
|
||||
|
Loading…
x
Reference in New Issue
Block a user