Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Avoid automatic entity encoding

    Qt WebKit
    2
    3
    1113
    Loading More Posts
    • 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.
    • raven-worx
      raven-worx Moderators last edited by

      Hi,
      i couldn't find any possibility or workaround to get the HTML source from a QWebView with preserved entities.
      So i hope someone can point me to something i've overseen ;)

      The problem is, when i set the HTML (containing entities) manually to the QWebView and try to retrieve later i get a QString with the entities encoded to their raw corresponding unicode characters.

      best regards.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply Reply Quote 0
      • P
        prady_80 last edited by

        I have not tried this,
        Could you please check if this works?
        @
        QTextDocument text;
        text.setHtml(<The obtained HTML here>);
        QString plain = text.toPlainText();
        @

        1 Reply Last reply Reply Quote 0
        • raven-worx
          raven-worx Moderators last edited by

          no this doesn't work either. Which would have surprised me ... since a QTextDocument doesn't even support the full HTML subset?

          I'm working on a WYSIWYG editor and thus it's mandatory to preserve the entities which the user added to the document.

          A easy work around would be to iterate over the whole source string and replace every contained QChar with QChar::unicode() > 255 to &#UNICODE and/or hold a list of the most common used entities.

          I think that's the way i will have to go.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply Reply Quote 0
          • First post
            Last post