<br><br><div class="gmail_quote">2008/12/1 Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Mon, 1 Dec 2008 11:23:38 +0100, "piotr maliński" <<a href="mailto:riklaunim@gmail.com">riklaunim@gmail.com</a>><br>
wrote:<br>
<div class="Ih2E3d">> I'm trying to use QScintilla with a file opened with QFile (and not<br>
Python<br>
> functions). With files that contain ascii only characters it works, but<br>
for<br>
> utf-8 files with non-ascii character it doesn'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>
<br>
</div>Have you tried it without the Text flag?<br>
<div class="Ih2E3d"></div></blockquote><div><br><br>Removing it doesn't help<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><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<br>
QsciScintilla.setText()<br>
> has an invalid type) as it wants QString and not QByteArray :) Is there a<br>
> file encoding safe way to open a text file and pass it to QScintilla<br>
> widget?<br>
> I was using codecs and normal open with try/except - try another way/<br>
> solution but it was bit uggly, and had problems with some files<br>
encodings.<br>
<br>
</div>You could also try QsciScintilla.read().<br>
<br>
Note, QScintilla has its own mailing list.<br>
<font color="#888888"><br>
Phil<br>
</font></blockquote></div><br>Didn't seen that one ;) <br><br>I'll stick to codecs for now. Next will be detecting file encoding and encode the text accordingly so it would display correctly :)<br>