将 std::string 转换为 QString
我有一个 std::string content,我知道它包含 UTF-8 数据.我想将其转换为 QString.如何避免 Qt 中的 from-ASCII 转换?
I've got an std::string content that I know contains UTF-8 data. I want to convert it to a QString. How do I do that, avoiding the from-ASCII conversion in Qt?
推荐答案
有一个 QString 函数叫做 fromUtf8 需要一个 const char*:
There's a QString function called fromUtf8 that takes a const char*:
QString str = QString::fromUtf8(content.c_str());
相关文章