[Interest] Difference between QUrl::fromEncoded and QUrl::fromPercentEncoding ?

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Tue Aug 13 14:11:21 CEST 2013


On Tue, Aug 13, 2013 at 4:14 PM, Richard Turner <turner at yiran.org> wrote:

>  Hi,
>     QString str = "http%3A%2F%2F192.168.1.1%3A80%2Fservlet%2Fcom.mcdonalds.report.view.excel.ExcelReportServlet%3Ffile%3D4162%26columns%3D0%26srcType%3DdefineBean%26width%3D0%26height%3D0%26reportParamsId%3D101767%26cachedId%3D4163%26t_i_m_e%3D1376389959473&pageStyle=0";
>     QUrl downloadUrl1 = QUrl::fromEncoded(str.toUtf8());    QUrl downloadUrl2 = QUrl::fromPercentEncoding(str.toUtf8());
>
>     assert(downloadUrl1.toString() == downloadUrl2.toString());    assert(downloadUrl1 == downloadUrl2);
>
> Why is the second assertion fails when the first assertion still passes? What is the underlying difference between QUrl::fromEncoded and QUrl::fromPercentEncoding?
>
>
I think you're using Qt4 since the first assert is passing (in Qt5 it
would've failed as the default arg to QUrl::toString() has changed).

QUrl::fromEncoded assumes the string is ASCII encoded only. Is there a
non-ASCII char somewhere in that url?

-mandeep




> Thanks!
>
> Richard
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130813/4fbc5d8f/attachment.html>


More information about the Interest mailing list