How to add a text encoding alias ?



  • 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 :)



  • 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.



  • 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... ??


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.