Results 1 to 3 of 3

Thread: Convert to html percent encoding

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Convert to html percent encoding

    Your QString is a collection of Unicode character codes. The character 'À' is Unicode code point U+00C0. The UTF-8 encoding for that code point is two bytes 0xC3 0x80. I think you can see where your result is coming from. This behaviour is exactly as documented http://doc.qt.io/qt-5/qurl.html#toPercentEncoding

    The original RFC talks about encoding the ASCII value of reserved characters: there is no ASCII code for 'À'. RFC 3986, in 2005, changed this to UTF-8, which explains the Qt behaviour.

    Your server is expecting that the character has been encoded with a local eight bit encoding (probably Windows CP1252) where that character would be a single byte 0xC0. It is possible the server triggers UTF-8 handling if the request has an Accept-Charset header listing utf-8, so that is worth a try. If not, you may have to manually encode the bytes out of QString:toLocal8Bit() to get the result your server expects.

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

    bull3t (31st October 2016)

Similar Threads

  1. QUrl Percent Encoding and addQuery
    By ttimt in forum Newbie
    Replies: 3
    Last Post: 31st March 2015, 18:16
  2. HTML Unicode ampersand-encoding
    By Neptilo in forum Qt Programming
    Replies: 2
    Last Post: 19th December 2012, 23:01
  3. Convert html to bbcode
    By abrahametalero in forum Newbie
    Replies: 1
    Last Post: 2nd March 2011, 23:14
  4. Encoding/decoding a string to URL and HTML
    By ultr in forum Qt Programming
    Replies: 4
    Last Post: 25th September 2010, 22:40
  5. How to convert text to HTML in QTextEdit
    By Roszko in forum Newbie
    Replies: 5
    Last Post: 31st December 2009, 10:40

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.