求问,显示成功,但是结果显示为乱码?
Ta的回复 :我使用mingw编译的,输出时gbk格式,把原结果转为gbk格式输出就行了 string UTF8ToGBK(const std::string& strUTF8) { int nLen = MultiByteToWideChar(CP_UTF8, 0, strUTF8.c_str(), -1, NULL, 0); unsigned short * wszGBK = new unsigned short[nLen + 1]; memset(wszGBK, 0, nLen * 2 + 2); MultiByteToWideChar(CP_UTF8, 0, strUTF8.c_str(), -1, (LPWSTR)wszGBK, nLen); nLen = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)wszGBK, -1, NULL, 0, NULL, NULL); char *szGBK = new char[nLen + 1]; memset(szGBK, 0, nLen + 1); WideCharToMultiByte(CP_ACP,0, (LPWSTR)wszGBK, -1, szGBK, nLen, NULL, NULL); std::string strTemp(szGBK); delete[]szGBK; delete[]wszGBK; return strTemp; } string gbk = UTF8ToGBK(result.toStyledString()); cout << "语音识别本地文件结果:" << endl << gbk;