Qt将中文转换成unicode字符串
QString CTestManager::stringToUnicode(QString str) { const QChar *q; QChar qtmp; QString str0, strout; int num; q=str.unicode(); int len=str.count(); for(int i=0;i<len;i++) { qtmp =(QChar)*q++; num= qtmp.unicode(); if(num<128) strout+="\\u00"; //英文或数字前加"00" else strout+="\\u"; str0=str0.setNum(num,16);//变成十六进制数 if(1 == str0.count()) str0 = "0" + str0; //注意!!! strout=strout+str0; } return strout; }
转载于:https://blog.csdn.net/qiangzi4646/article/details/50498565