[Qt-interest] Reading text files in Windows using QTextStream doesn't work with unicode
Ellen Kestrel
dragonflykes at gmail.com
Fri Jan 21 01:51:39 CET 2011
Reading text from a file saved with UTF-8 encoding, "á" is imported as "á",
etc. I am using:
QFile file (filename);
QTextStream in (&file);
file.open (QIODevice::ReadOnly | QIODevice::Text);
QString line = "";
while (!in.atEnd ()) {
line = in.readLine ();
...
}
The exact same code, when compiled in linux and executed on the exact same
file, has no problems. The app font is manually set in main () to be a font
that supports unicode. This is Qt 4.7.1. Anyone know what kind of Windows
weirdness would cause this, or how it could be fixed? Interestingly,
reading in an XML document using the QDom classes does not seem to have this
problem, in either OS.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110120/633f2058/attachment.html
More information about the Qt-interest-old
mailing list