[Qt-interest] QString::fromLocal8Bit vs locales
Thiago Macieira
thiago at kde.org
Sat Aug 20 11:53:00 CEST 2011
On Saturday, 20 de August de 2011 10:20:23 Imre PÉNTEK wrote:
> Well, I didn't forgot. I can't tell how and why a QCoreApplication would
> help me, but anyways I modified my code like this:
It helps because QCoreApplication initialises the C library's locale subsystem
(i.e.a call to setlocale(LC_ALL, ""); ). That initialisation is necessary so
the system codec works, as iconv (part of libc) uses libc's concept of locale
to determine the encoding.
Without QCoreApplication, iconv will consider the locale as ASCII 7-bit. I
believe the code in the QIconvCodec will actually switch to Latin 1 under
those circumstances.
> now at least both fromLocal8Bit and fromUtf8 works when native charset is
> UTF-8. However when native charset is Latin-2 none of them are correct.
> FromLocal8Bit now only deals with ascii characters:
What was your Latin 2 locale? Can you also produce a properly-encoded Latin 2
error message with non-ASCII characters from system command-lines like ls?
E.g.: ls filenamethatdoesntexist
mkdir /root-dir-not-as-superuser
Another way to test is to use the iconv tool:
echo śčš | LC_ALL=your_locale_here iconv -f utf-8
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
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/20110820/e454fa7b/attachment.bin
More information about the Qt-interest-old
mailing list