QString::toLocal8Bit得听QTextCodec::codecForLocale的

这个函数用了这么久,到今天程序出错才发现这个问题。。。也就是说,必须设置
QTextCodec *codec = QTextCodec::codecForName("System");
toLocal8Bit才能转换成本地字符
http://doc.qt.io/qt-5/qstring.html#toLocal8Bit

如果系统Codec设置成UTF-8,那么toLocal8Bit转换立刻就乱套了。
但不知怎么才能系统Codec设置UTF-8,又不影响QString转换成本地字符?

posted @ 2016-01-07 18:46  findumars  Views(1065)  Comments(0Edit  收藏  举报