ini文件读写中文

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sdwfkfq/article/details/78459390
    只要读写统一使用一个编码,并用setIiniCodec指定,就可以读写中文。
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
    QString strPath = QCoreApplication::applicationDirPath()+"/sayezb.ini";
    QSettings *configIniRead1 = new QSettings(strPath, QSettings::IniFormat);
    configIniRead1->setIniCodec("UTF-8");
    configIniRead1->setValue("/database/skr", "分店");
    delete configIniRead1;
    QSettings *configIniRead = new QSettings(strPath, QSettings::IniFormat);
    configIniRead->setIniCodec("UTF-8");
    QString str = QString::fromUtf8(configIniRead->value("/database/skr").toByteArray());
    delete configIniRead;


                                    
展开阅读全文

没有更多推荐了,返回首页