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. QWebView not displaying unicode characters

QWebView not displaying unicode characters

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.5k 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.
  • K Offline
    K Offline
    kumararajas
    wrote on last edited by kumararajas
    #1

    Hello,

    I am not sure why QWebView is not displaying the unicode characters on the HTML page. HTML has the charset="utf-8" as well.
    And I have also tried to do

    webview->settings()->setDefaultTextEncoding("utf-8");
    

    Still no success. Any thoughts?

    Thanks,
    Kumara

    --Kumar

    RatzzR 1 Reply Last reply
    0
    • K kumararajas

      Hello,

      I am not sure why QWebView is not displaying the unicode characters on the HTML page. HTML has the charset="utf-8" as well.
      And I have also tried to do

      webview->settings()->setDefaultTextEncoding("utf-8");
      

      Still no success. Any thoughts?

      Thanks,
      Kumara

      RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on last edited by
      #2

      @kumararajas
      Did you try

      view->settings()->setDefaultTextEncoding("utf-8");

      --Alles ist gut.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kumararajas
        wrote on last edited by
        #3

        Hi
        I did mention in my post that, I have tried the same. (Aah! syntax typo).

        No success..

        --Kumar

        RatzzR 1 Reply Last reply
        0
        • K kumararajas

          Hi
          I did mention in my post that, I have tried the same. (Aah! syntax typo).

          No success..

          RatzzR Offline
          RatzzR Offline
          Ratzz
          wrote on last edited by Ratzz
          #4

          @kumararajas
          Have you tried this http://doc.qt.io/qt-4.8/qtextcodec.html#setCodecForCStrings
          Aww its removed in Qt5 http://doc.qt.io/qt-5/sourcebreaks.html

          --Alles ist gut.

          K 1 Reply Last reply
          1
          • RatzzR Ratzz

            @kumararajas
            Have you tried this http://doc.qt.io/qt-4.8/qtextcodec.html#setCodecForCStrings
            Aww its removed in Qt5 http://doc.qt.io/qt-5/sourcebreaks.html

            K Offline
            K Offline
            kumararajas
            wrote on last edited by
            #5

            @Ratzz Hey! Thanks! Your post given me the clue to look at codec point of view.
            Problem is fixed.

            While reading the file, read with codec, so that there is no loss.

            Here is the solution -

                QFile file( fileName );
                file.open( QIODevice::ReadOnly | QIODevice::Text );
                QTextStream out( &file );
                out.setCodec( "utf-8" );
                QString myData = out.readAll();
            

            This solves the problem of displaying unicode characters that present in HTML page.

            --Kumar

            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