Hello,
I use QString::toLocal8Bit() on Linux with a UTF-8 locale (eg, fr_FR.UTF-8, en_US.UTF-8). What is strange is that I do not get the same results as with QString::toUtf8(). For example, the following code:
Qt Code:
#include <QString> #include <iostream> int main(int, char **) { std::cout << array.constData(); return 0; }To copy to clipboard, switch view to plain text mode
outputs a single byte E9 (in hexadecimal). If toLocal8Bit is replaced with toUtf8, the program outputs the sequence of bytes C3 A9 as expected.
C3 A9 and E9 are the encodings of "é" in UTF-8 and Latin-1 respectively. In other words, toLocal8Bit() outputs Latin-1 in this case, although the locale is UTF-8.
This is quite a problem, as I rely on QString::toLocal8Bit() to pass filenames to system calls for example. Has anyone come accross this issue before? Is there any reliable alternative?
Bookmarks