原文地址::https://blog.csdn.net/gllg1314/article/details/46989953
相关文章
1、Qt Creator 设置默认编码格式为 UTF-8----https://blog.csdn.net/abeldeng/article/details/24770907
2、Qt中Error:Could not decode "xxx.cpp" with "System"-encoding.Editing not possible.的解决方案----https://blog.csdn.net/mnonm_mnonm_mnonm/article/details/8480700
qt解析tcp通信传来的xml时,中文有乱码
解决方法:
头文件添加 #include <QTextCodec>
QByteArray tmpQBA = m_pSocket->readAll();
QTextCodec *tc = QTextCodec::codecForName("GBK");
QString tmpQStr = tc->toUnicode(tmpQBA);
//如下转换会导致中文乱码
QString tmpQStr = QVariant(tmpQBA).toString();