[Qt-interest] Reading text files in Windows using QTextStream doesn't work with unicode
Thiago Macieira
thiago at kde.org
Fri Jan 21 06:51:06 CET 2011
On Thursday, 20 de January de 2011 19:21:48 Ellen Kestrel wrote:
> Ahh, thank you, that did work. Does it just misrender the characters if the
> file is in the wrong encoding, or does something more problematic happen?
It's not about rendering. It's about parsing the file: it will be wrong. The
string lengths will be wrong. In some languages, the text may be completely
unreadable and undecipherable.
> Is there a way to automatically detect (or try to detect) the encoding of a
> file?
No. That's why encoding of a file must be always:
1) pre-defined and never change, like UTF-8 or UTF-16
2) saved along with the file and easily retrievable
Guessing is possible, with a certain degree of accuracy. But it's impossible
to reach 100%.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110121/67776e5d/attachment.bin
More information about the Qt-interest-old
mailing list