Accentuated Characters in pythonqt
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
Hi,
I want to send paths from C++ to python, and for this I need to be able to transfer some strings from the main C++ code to the python script. However, I am having trouble with accentuated characters:
If I execute this code:
Then I get the following output from python:
Any idea as to how I could transfer those accentuated characters?
Last edit: Emmanuel Nicolas 2015-06-04
I found that this is actually also the case in the PyScriptingConsole example: if you type print('é') in the command line, you end up with the same unicode error.
Last edit: Emmanuel Nicolas 2015-06-06
Further testing:
If I am doing print('é') from a py file that I evaluate, no problem upon calling the function.
When doing
QString e = QString::fromUtf8("é");
pythonModule.evalScript(QString("print(%1)").arg(e));
I get the error message:
print(�)
SyntaxError: invalid character in identifier
But doing:
pythonModule.evalScript("print('é')");
pythonModule.evalScript("print('\u00e9')");
I still get:
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe9 in position 0: unexpected end of data
Typing all these possibilities straight in python console perfectly works, so I assume it is an encoding problem. Any ideas?