SPlatten SPlatten - 1 year ago 217
C++ Question

Qt translate escape sequence

I have:


I want to translate this for display into ºC

I'm using Qt 5.6, is there a built in function I can call to translate this sequence?

Qt has functions to translate the symbol to an escape sequence:

QString QString::toHtmlEscaped()

But what I need is the corresponding function to translate back to the original.

Answer Source

You can use QTextDocument or QTextDocumentFragment to decode html entities:

QString html_string = "ºC";
QString plain_string = QTextDocumentFragment::fromHtml(b).toPlainText();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download