Why Unicode fonts are not showing properly in the QTextBrowser when Unicode contents are read from an html file?

a 夏天 提交于 2019-12-02 03:22:04

You read a binary file into QString but do not tell the program, which bytes correspond to which unicode character, i.e. you don't specify the "encoding" aka. "codec".

To debug your problem, ask QTextStream which codes it uses by default:

QTextStream textStream1(&file);
qDebug() << textStream1.codec()->name();

On my Linux system, that is already "UTF-8" but it might be different on your system. To force QTextStream interpreting the input as UTF-8, use QTextStream::setCodec.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!