Avoid automatic entity encoding


  • Moderators

    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.



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


  • Moderators

    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.


Log in to reply
 

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