QByteArray MyClass::utf8ToGbk(const QString &str)
{
QTextCodec* temp = QTextCodec::codecForLocale();
QTextCodec* utf8 = QTextCodec::codecForName("UTF-8");
QTextCodec* gbk = QTextCodec::codecForName("gbk");
QTextCodec::setCodecForLocale(utf8);
QString strUnicode = utf8->toUnicode(str.toLocal8Bit().data());
QTextCodec::setCodecForLocale(temp);
return gbk->fromUnicode(strUnicode);
}
UTF8转GBK2312
最新推荐文章于 2023-08-25 15:51:25 发布