[Qt-interest] QFtp put functions has a bug?
Thiago Macieira
thiago.macieira at trolltech.com
Wed Feb 11 17:38:12 CET 2009
Em Quarta-feira 11 Fevereiro 2009, às 16:28:45, Pavel Koshevoy escreveu:
> Thiago Macieira wrote:
> > tank wrote:
> >> Thiago Macieira 写道:
> >>> QFtp only supports Latin1.
> >>
> >> i want to know
> >> how to put a file that's name is chinese ???
> >
> > You can't. QFtp is limited to Latin 1.
>
> That's broken. Is there a technical reason for this?
Yes: all commands are queued in QFtp using a QStringList. It sends them one by
one and checks that they were successful.
However, since they are stored in a QStringList, QFtp has to know which
encoding to use. The code just assumes it's Latin 1 and has no way of changing
it.
Also note that the Qt API uses QString for filenames, meaning it always has to
convert to the 8-bit locale format when operating with files on Unix platforms.
When dealing with remote servers, however, you can't assume the locale
encoding is valid.
QFtp therefore needs a new feature to specify which codec to use for remote
filenames.
> Will QFtp support
> international file names (QString or UTF-8 std::string) in the future?
No, it will not. We're not adding any new features to QFtp anymore.
Instead, we may add that feature to QNetworkAccessManager. In fact, it should
be considered a bug in it: since it operates on URLs, the IRI specification
(RFC 3987) applies. That means URLs are always encoded in UTF-8. The failure
to use UTF-8 in file names is a bug (because we use QFtp behind the scenes).
However, URLs can hold arbitrary binary data in the path: if your remote
server uses an encoding different from UTF-8, you can encode it with percent-
encoding in the URL. For example, the file "中国.txt" would be encoded as:
ftp://someserver/path/%d6%d0%b9%fa.txt
in GB2312.
--
Thiago Macieira - thiago.macieira (AT) nokia.com
Senior Product Manager - Nokia, Qt Software
Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090211/276abd64/attachment.bin
More information about the Qt-interest-old
mailing list