[Qt-interest] QWebPage: percent encoded query items use Latin1 instead of UTF-8 ?
Joachim Förster
JOFT at gmx.de
Sun Jan 16 20:44:46 CET 2011
Hi all,
currently I'm working on a little QtWebKit based tool. I think I
discovered what could be a bug somewhere QtWebKit and with this mail I'd
like to know if anybody encounter the following behaviour:
On one of the pages shown in my app, there are links/URLs with query
items which have non-ASCII characters in their values (like german umlauts).
Of course, I applied percent encoding within the HTML source of the
page, example: Ü => %C3%9C
Actually the HTML source is generated and the query items are encoded
using QUrl::toPercentEncoding().
Clicking on such a link within a QWebView/Page unfortunately results in
a navigation request which shows me a differently encoded URL:
The %C3%9C appears as %DC .
If I'm right, %DC is kind of percent-encoded Latin1 instead of %C3%9C
which is percent-encoded UTF-8 - for "Ü".
Now, the problem is: Using QUrl::queryItemValue(somekey) results in a
QString with an invalid character (0xffffd), because first
queryItemValue() uses QUrl::fromPercentEncoding() to undo the
percent-encoding and than it uses QString::fromUtf8() to get the final
QString (return value of queryItemValue()).
Obviously (?) it should have used QString::fromLatin1(). But I think,
that the change in encoding shouldn't happen in the first place.
The big question is: Why did the encoding change? As far as I understand
the Qt source code (qurl.cpp) it should stay percent-encoded-UTF-8.
Am I doing something wrong? Or is this a bug in Qt?
I'm currently using Qt 4.7.1 .
Thanks,
Joachim
More information about the Qt-interest-old
mailing list