Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. How to add a text encoding alias ?
Forum Update on Monday, May 27th 2025

How to add a text encoding alias ?

Scheduled Pinned Locked Moved Qt WebKit
3 Posts 2 Posters 2.1k Views
  • 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.
  • Y Offline
    Y Offline
    yolongyi
    wrote on 24 Jul 2012, 10:49 last edited by
    #1

    Hi

    I'm trying to parse html with QtWebkit.
    The charset of the html is given by meta tag. ( like below )

    <meta http-equiv="Content-Type" content="text/html; charset=x-sjis">
    ( URL: "http://www.kk-bestsellers.com/company/index.htm":http://www.kk-bestsellers.com/company/index.htm )

    charset is x-sjis as you can know...

    The page can not be shown properly since qtwebkit can not find the proper encoding,
    but Chrome, IE .. all show well with Shift_JIS.

    x-sjis is an old presentation of Shift_JIS ( as far as I know )

    so I want to add encoding alias from x-sjis to Shift_JIS to qtwebkit.
    but I could not find the way..

    how can I do it ?

    thanks in advance :)

    1 Reply Last reply
    0
    • A Offline
      A Offline
      akonradwesolutions
      wrote on 24 Jul 2012, 15:49 last edited by
      #2

      Is this the only content you have to display? If so you can try to set the default encoding of the entire [[Doc:QWebPage]] or [[Doc:QWebView]]:

      @
      myWebView->settings()->setDefaultTextEncoding("Shift-JIS");
      // or
      myWebPage->settings()->setDefaultTextEncoding("Shift-JIS");
      @

      A more elaborate solution would be to create a proxy [[Doc:QTextCodec]] plugin that wraps the Shift-JIS codec. I am not entirely sure that QtWebkit uses QTextCodec for unicode conversions, though.

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yolongyi
        wrote on 27 Jul 2012, 08:35 last edited by
        #3

        I've read a part of code for encoding.
        In my fedora package, it uses Qt unicode.

        I've a little bit modified and made it parse x-sjis with Shift_JIS.
        It works well.

        but I don't want to edit QtWebKit code itself, I want to control it from my code.
        Till now I couldn't find a way.

        Do you have anything helpful... ??

        1 Reply Last reply
        0

        1/3

        24 Jul 2012, 10:49

        • Login

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