qt 中utf8 gbk字符互转


QTextCodec *XXXClassFun::GetGBKCoder()
{
    static QTextCodec *code = QTextCodec::codecForName("gb2312");
    return code;
}


#define UNICODE_TO_GBK(a) XXXClassFun::GetGBKCoder()->fromUnicode(a).data()
#define GBK_TO_UNICODE(a) XXXClassFun::GetGBKCoder()->toUnicode(a).toStdString().c_str()


const string strFile = "F:/Program Files (x86)/Netdragon/宗文路径/a.exe";
string strFileUni = UNICODE_TO_GBK(strFile.c_str());

char szValue[256] = "F:/Program Files (x86)/Netdragon/宗文路径/a.exe";
string strValue = GBK_TO_UNICODE( szValue );
 

猜你喜欢

转载自blog.csdn.net/qq_30377315/article/details/128931361
今日推荐