PythonQtScriptingConsole (183): replace with PyCompilerFlags pyCFlags; pyCFlags.cf_flags = PyCF_SOURCE_IS_UTF8; p.setNewRef(PyRun_StringFlags(code.toUtf8(), Py_single_input, dict, dict, &pyCFlags));
PythonQt.cpp (605) replace with: PyCompilerFlags pyCFlags; pyCFlags.cf_flags = PyCF_SOURCE_IS_UTF8; p.setNewRef(PyRun_StringFlags(script.toUtf8(), start, dict, dict, &pyCFlags));
After that you can write something like this: push1.text = 'yourlanguage'
Thanks for the hint! Why is this flag not default?
Hello! If the script is executed using the evalFile, for example,
... console = new PythonQtScriptingConsole (0, context); ... PythonQt:: self () -> getMainModule (). EvalFile (": example.py"); console-> appendCommandPrompt (); console-> show ();
then everything is fine with the encoding of the string. The script is simple:
val = 'Русский' print val
If those statements are executed in PythonQtScriptingConsole, the output is unreadable, like this: Р СѓСЃСЃРєРёР№ In what may be the problem?
Yours faithfully, Sergey.
To enable utf-8 support is sufficient to make the substitution: PythonQtScriptingConsole.cpp (183): replace with p.setNewRef(PyRun_String(code.toAscii().data(), Py_single_input, dict, dict));
PythonQt.cpp (611 - из репозитория) replace with: p.setNewRef(PyRun_String(script.toAscii().data(), start, dict, dict));
Line numbers are indicated for the code from the repository (199 revision). It has no problems in the console, too (see above).
Log in to post a comment.
PythonQtScriptingConsole (183): replace with
PyCompilerFlags pyCFlags;
pyCFlags.cf_flags = PyCF_SOURCE_IS_UTF8;
p.setNewRef(PyRun_StringFlags(code.toUtf8(), Py_single_input, dict, dict, &pyCFlags));
PythonQt.cpp (605) replace with:
PyCompilerFlags pyCFlags;
pyCFlags.cf_flags = PyCF_SOURCE_IS_UTF8;
p.setNewRef(PyRun_StringFlags(script.toUtf8(), start, dict, dict, &pyCFlags));
After that you can write something like this:
push1.text = 'yourlanguage'
Thanks for the hint!
Why is this flag not default?
Hello!
If the script is executed using the evalFile, for example,
then everything is fine with the encoding of the string. The script is simple:
If those statements are executed in PythonQtScriptingConsole, the output is unreadable, like this: Р СѓСЃСЃРєРёР№
In what may be the problem?
Yours faithfully,
Sergey.
To enable utf-8 support is sufficient to make the substitution:
PythonQtScriptingConsole.cpp (183): replace with
p.setNewRef(PyRun_String(code.toAscii().data(), Py_single_input, dict, dict));
PythonQt.cpp (611 - из репозитория) replace with:
p.setNewRef(PyRun_String(script.toAscii().data(), start, dict, dict));
Line numbers are indicated for the code from the repository (199 revision).
It has no problems in the console, too (see above).