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

Thiago Macieira thiago.macieira at intel.com
Tue Aug 13 18:00:45 CEST 2013

On terça-feira, 13 de agosto de 2013 18:44:41, Richard Turner wrote:
>      QUrl  downloadUrl1  =  QUrl::fromEncoded(str.toUtf8());
>      QUrl  downloadUrl2  =  QUrl::fromPercentEncoding(str.toUtf8());

Please note QUrl::fromEncoded returns a QUrl. QUrl::fromPercentEncoding 
returns a QString. That's the difference.

Your code above also calls the QUrl constructor taking a QString, which is a 
big no-no in Qt 4 code, but entirely acceptable in Qt 5.

On the other hand, if you have any percent sequences not making UTF-8, 
QUrl::fromPercentEncoding will mangle them.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130813/f27bd96b/attachment.sig>

More information about the Interest mailing list