Encoding problem in the file ioslave

Thiago Macieira thiago at kde.org
Mon Sep 1 07:27:36 BST 2008


Michael Pyne wrote:
>Well it would still be nice if people were able to open files that are
> sitting there right on the disk.  Even after you extract the tar you
> cannot navigate into the directory with Dolphin.  And the directory
> really is there.

You can't.

QFile won't let you because there's no way you can represent a broken 
encoding in QString. QDir and QDirIterator will also simply skip the file 
as if it didn't exist.

Be careful if you choose to change everything to QByteArray. The KIO 
protocol is well established, so you can't change the meaning of anything 
there. I would recommend instead to use the URL field, but be really 
careful to use the encoded components of QUrl/KUrl: QUrl suffers from the 
same problem of not being able to represent a random binary byte in a 
QString, so it simply won't.

And if you use QUrl or QByteArray, you'll have to completely bypass QFile 
everywhere! I.e. you'll have to use the native 8-bit functions like 
open(2) or fopen(3) and *never* QFile.

Also remember that Windows (we seem to care about that platform now, 
right?) uses Unicode to store filenames. If you convert from Unicode to 
8-bit, make sure you're using UTF-8, not the local encoding for that 
platform, or use URLs. So in the everywhere above where you converted 
from QFile to the non-Win32 functions, be sure to use the local encoding 
on Unix, but UTF-8 on Windows.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080901/74ea6aab/attachment.sig>


More information about the kde-core-devel mailing list