[Interest] Difference between QUrl::fromEncoded and QUrl::fromPercentEncoding ?
thiago.macieira at intel.com
Tue Aug 13 19:50:49 CEST 2013
On quarta-feira, 14 de agosto de 2013 00:35:47, Richard Turner wrote:
> OK. Now the problem is, when I use downloadUrl1(result from fromEncoded)
> to make a QNetworkRequest (HTTP GET), I always detect an error: Protocol
> "" is unknown.
> When I switch to use downloadUrl2, all is good.
That was expected. Look at what your URL was:
Try pasting that in a browser and see what happens.
The behaviour differs because QUrl::fromEncoded tries to interpret that as a
URL. It has no scheme, so the entire thing is the path of the URL. Since it
has no scheme, QNetworkAccessManager is correct in saying that "Protocol '' is
QUrl::fromPercentEncoding does no interpretation. It simply decodes the
percents. After that, you call the QUrl constructor on a different URL. Let me
repeat: on a *different* URL.
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 190 bytes
Desc: This is a digitally signed message part.
More information about the Interest