PDA

View Full Version : strange output using topercentencoding()



raj_iv
5th December 2012, 05:20
pls check th below code n its strange output...i m not able to figure it out

QString params = QString("q=%1&fields=%2")
.arg(QByteArray("mimeType='application/json'").toPercentEncoding().data())
.arg(QByteArray("items").toPercentEncoding().data());

Output:
q=mimeType%3D%27applicationitemsFjson%27&fields=items

why items coming just after application...wat happened to '/' percent encoded part. If i remove '/' then output is fine.

wysota
5th December 2012, 05:56
And what is so strange here? "/" expands to %2F and thus "%2" gets expanded to the second argument given.

raj_iv
5th December 2012, 06:45
thanks wysota for the explanation...
so wats the remedy...hw do i form the string so tat strings in arg() only get percent encoded.

Added after 10 minutes:

but in first arg() single quote ' getting encoded to %27 but its not expanding to second argument...

wysota
5th December 2012, 07:25
thanks wysota for the explanation...
so wats the remedy...
The remedy is to replace the percents later or to not use arg().


but in first arg() single quote ' getting encoded to %27 but its not expanding to second argument...
Maybe it'd be expanded to 27th argument.