Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt5 encoding error #32

Closed
photoniker opened this issue May 26, 2023 · 0 comments
Closed

Qt5 encoding error #32

photoniker opened this issue May 26, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@photoniker
Copy link
Contributor

photoniker commented May 26, 2023

In Qt5, when saving and reloading a file with special characters like mu, degree... , these characters are wrongly displayed (usually replaced by ?)

[Issue created by M. Gronle: 2015-01-29]

[Comment created by M. Gronle: 2015-01-29]
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 0eb9449>>

[Comment created by Johann Krauter: 2015-01-29]
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.

@photoniker photoniker added the bug Something isn't working label May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants