Qt5 encoding error
Issue #32
resolved
In Qt5, when saving and reloading a file with special characters like mu, degree... , these characters are wrongly displayed (usually replaced by ?)
Comments (2)
-
-
reporter - changed status to resolved
fixes issue
#32(Qt4/5 encoding error). In Qt5 QString(QByteArray ba) assumes that ba is utf8 encoded, in Qt4 it assumed ascii (latin1). Now, the optional language::codec setting parameter defines the codec for reading and writing python script files (default: latin1). Additionally, the python codec for stdout and stderr stream is set to latin1 and the itom-stream class handles every input to be latin1 decoded.→ <<cset 0eb944905a42>>
- Log in to comment
In Qt4, QScintilla was set to utf8 mode, scripts are loaded with utf8 standard in scriptEditorWidget::openFile and saved to latin1 in scriptEditorWidget::saveFile. Since the command line was in utf8, single commands to python have been converted to utf8 in PythonEngine::runString.
QString text = QString::fromLatin1(file.readAll());
In Qt5, it seems that the latin1 coded file must be read with utf8 standard and QScintilla returns a latin1 encoded string in its text-method such that python needs to get a toLatin1() decoded byte-array.