[Qt-interest] Non-Ascii filenames with QFile

Thiago Macieira thiago at kde.org
Wed Feb 10 18:21:11 CET 2010


Em Quarta-feira 10. Fevereiro 2010, às 17.35.36, Santosh Puranik escreveu:
> I do not think that is the problem, even if I use fromUtf8() as above, I 
> still have the same issue. I'll explain my actual use case in more detail:
> 
> 1) We get the filename from a PC over USB.
> 2) The strings that we receive are encoded in UTF-16 LE. So, we make a 
> path out of this: QString filePath = QString(<Root path>) + 
> QString::fromUtf16(<raw UTF-16 LE data>).
> 3) Then create that file with QFile: QFile f(filePath); 
> f.open(QIODevice::ReadWrite).
> 4) And this still fails.
> 
> The problem IMO is in when QT tries to encode the file path to the 
> system locale's charset ... which is not UTF-8 on my system:
> 
> ~ $ locale charmap
> ANSI_X3.4-1968

Qt considers any file name that falls outside the system locale to be filesystem 
corruption.

If you wish to access non-ASCII file names, you must not use ASCII as locale.

-- 
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/20100210/90946af4/attachment.bin 


More information about the Qt-interest-old mailing list