CString 编码_utf8到gbk(CString utf8文本){ USES_CONVERSION; std::string(*Utf8ToGbk)(const char* src_str) = [](const char* src_str) { int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0); wchar_t* wszGBK = new wchar_t[len + 1]; memset(wszGBK, 0, len * 2 + 2); MultiByteToWideChar(CP_UTF8, 0, src_str, -1, wszGBK, len); len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL); char* szGBK = new char[len + 1]; memset(szGBK, 0, len + 1); WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL); std::string strTemp(szGBK); if (wszGBK) delete[] wszGBK; if (szGBK) delete[] szGBK; return strTemp; }; std::string strUtf8 = W2A(utf8文本); std::string strGbk = Utf8ToGbk(strUtf8.c_str()); CString str = A2W(strGbk.c_str()); return str; }