samedi 25 juillet 2015

Qt QString's toHtmlEscaped doesn't work

I'm writing a QString with some non-ascii characters to a html-file like so:

QString string = u8"äöü";
std::ofstream f("myfile.html");
f << "<h1>" << qPrintable(string.toHtmlEscaped()) << "</h1>\n";

So I call toHtmlEscaped(), but nevertheless I get äöü. More strangely using that particular way to write the string to a file and printing that HTML-file to a PDF leads to correct encoding.

Any pitfall(s) I might have stepped in to?

Aucun commentaire:

Enregistrer un commentaire