Qt, QUrl, QUrlQuery: Encoding special character in a query string -


i create url query this:

qstring normalize(qstring text)     {         text.replace("%", "%25");         text.replace("@", "%40");         text.replace("‘", "%27");         text.replace("&", "%26");         text.replace("“", "%22");         text.replace("’", "%27");         text.replace(",", "%2c");         text.replace(" ", "%20");          return text;     }     qstring key = "usermail"; qstring value = "aemail@gmail.com";     qurlquery qurlqr;     qurlqr.addqueryitem(normalize(key), normalize(value));  qstring result = qurlqr.tostring(); 

the result that's expecting :

usermail=aemail%40gmail.com.  

but received:

usermail=aemail@gmail.com 

i don't know why. can me?

(i'm using qt5 on win7)

qurlquery's tostring default decodes percent encoding. if want encoded version try:

qurlqr.tostring(qurl::fullyencoded)

also don't need manually encode string replacing characters; instead use qurl::toencoded() (i suggest read qurlquery documentation).


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -