Results 1 to 2 of 2

Thread: encode in url.addQueryItem

  1. #1
    Join Date
    Mar 2011
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question encode in url.addQueryItem

    In my project I want to visit an url with some arguments and catch the return parameters. I take the following codes for test.
    QUrl url = QString("http://localhost/test")
    url.addQueryItem("test", QString("abc+bcd"));

    But the arguments my server received is "abc bcd". Plus is replaced by " ". I don't know how to fix it. Simply modifying the '+' character by "%2B" doesn't work.
    Who could help me? thanks very much!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,595
    Thanks
    13
    Thanked 1,588 Times in 1,517 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: encode in url.addQueryItem

    Qt should be encoding the literal '+' as %2B on your behalf. There is a bug that has been (I think incorrectly) closed as invalid: http://bugreports.qt.nokia.com/browse/QTBUG-10146

    You can work around it with this:
    Qt Code:
    1. url.addEncodedQueryItem("another", QUrl::toPercentEncoding("abc+bcd"));
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to ChrisW67 for this useful post:

    xyjian (29th March 2011)

Similar Threads

  1. Replies: 1
    Last Post: 29th March 2011, 10:12
  2. Encode/decode base 64 images
    By fitzy in forum Qt Programming
    Replies: 6
    Last Post: 28th October 2009, 18:38
  3. Encode html special characters
    By miraks in forum Qt Programming
    Replies: 4
    Last Post: 21st September 2009, 08:51
  4. QHttpResponseHeader encode & Save COOKIE value %20
    By patrik08 in forum Qt Programming
    Replies: 7
    Last Post: 8th April 2009, 22:22
  5. encode characters
    By smarinr in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2008, 06:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.