I&#39;m trying to use QScintilla with a file opened with QFile (and not Python functions). With files that contain ascii only characters it works, but for utf-8 files with non-ascii character it doesn&#39;t - the code snippet:<br>
############################<br>self.ui.editor.setUtf8(True)<br>...<br>text =QtCore.QFile(url)<br>text.open(QtCore.QIODevice.ReadWrite | QtCore.QIODevice.Text)<br>txt = QtCore.QString(text.readAll())<br>self.ui.editor.setText(txt)<br>
text.close()<br>############################<br><br>If I use:<br>self.ui.editor.setText(txt.toUtf8())<br>QSci will thow exception (TypeError: argument 1 of QsciScintilla.setText() has an invalid type) as it wants QString and not QByteArray :) Is there a file encoding safe way to open a text file and pass it to QScintilla widget? I was using codecs and normal open with try/except - try another way/ solution but it was bit uggly, and had problems with some files encodings.<br>