Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with QUrlQuery::toString(QUrl::FullyEncoded) (.toUtf8()) ,with character '+'
Forum Updated to NodeBB v4.3 + New Features

Problem with QUrlQuery::toString(QUrl::FullyEncoded) (.toUtf8()) ,with character '+'

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stephane78
    wrote on last edited by stephane78
    #1

    Hi,
    I have the following code :

    QUrlQuery postData;
    
    ....
    postData.addQueryItem("objet",objet);
    
    postData.addQueryItem("message",message);
    
    QByteArray b=postdata.toString(QUrl::FullyEncoded) .toUtf8(); 
    m_reponse = m_pNetManager->post(requete,  postData.toString(QUrl::FullyEncoded).toUtf8());
    

    When objet or message contains the character '+' ,the variable b contains this character not encoded (not as %) and the webservices php (api rest) receive a space character instead of '+'.I think that postData.toString(QUrl::FullyEncoded) has a bug because the character '+' must be encoded like '%n'....

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stephane78
      wrote on last edited by
      #2

      I have fixed it with

      objet.replace(QChar('+'),QString("%2B"));
      message.replace(QChar('+'),QString("%2B"));
      
      postData.addQueryItem("objet",objet);
      
      postData.addQueryItem("message",message);
      
      

      but it 'is a bug of the method QUrlQuery::toString(QUrl::FullyEncoded),that should encode the character '+' as "%2B"...
      my problem is solved.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Hi! This bug has been reported as QTBUG-50001.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stephane78
          wrote on last edited by
          #4

          OK thanks Wieland,
          I had this problem with version Qt 5.3.2 compiled from sources for windows, with 5.4.1 for linux and with 5.4.2 for MacOSX.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved