问题
在用qt往文件写入中文时,总是出现乱码
解决
QFile file;
QTextStream textStream;
file.setFileName("test.txt");
if (file.open(QIODevice::Append | QIODevice::Text)) {textStream.setDevice(&file);textStream.setCodec("UTF-8");
}
string arg = "测试";
QString tmpStr = QString(QString::fromLocal8Bit(arg.c_str()));
textStream<< tmpStr << endl;