1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Convert unicode result to UTF-8 string

This commit is contained in:
James Booth 2013-09-19 23:32:06 +01:00
parent 18a8be8935
commit 543c37ae17

View File

@ -166,11 +166,14 @@ python_before_message_displayed_hook(ProfPlugin *plugin, const char *message)
PyObject *result = PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
if (result != Py_None) {
char *result_str = NULL;
PyArg_Parse(result, "(s)", result_str);
if (PyUnicode_Check(result)) {
char *result_str = strdup(PyString_AsString(PyUnicode_AsUTF8String(result)));
Py_XDECREF(result);
return result_str;;
return result_str;
} else if (result != Py_None) {
char *result_str = strdup(PyString_AsString(result));
Py_XDECREF(result);
return result_str;
} else {
return NULL;
}