[Qt-interest] Non-latin characters in QString and char * on Windows
Andreas Pakulat
apaku at gmx.de
Wed Mar 2 22:38:00 CET 2011
On 02.03.11 23:05:25, Konstantin Tokarev wrote:
> Hi all,
>
> I need to convert QString, containg non-latin characters (specifically, cyrillic) to const char *,
> in order to open file with ifstream (requirement of 3rd party library). One may think that it's
> about QString::toLocal8Bit(), but it does not help on Windows!
>
> See attached program. On Linux with UTF-8 everything works fine with either toUtf8 or
> toLocal8Bit. On Windows (default encoding is CP1251) both functions return crap (different
> between each other). Of course, ifstream cannot open corrupted file paths.
>
> How to get proper representation of QString fileName in const char * ?
You want QFile::encodeName().
Andreas
More information about the Qt-interest-old
mailing list