c++ Ansi和Unicode相互转换
int Ansi_To_Unicode(string strSrc, wstring& strRet)
{
wchar_t wBuff[102400] = { 0 };
CHAR sBuff[102400] = { 0 };
int iRet = MultiByteToWideChar(CP_ACP, 0, strSrc.c_str(), -1, wBuff, 102400);
if (iRet > 0) {
strRet = wBuff;
return TRUE;
}
return FALSE;
}
int Unicode_To_Ansi(wstring strValue, string& strRet)
{
CHAR sBuff[102400] = { 0 };
int iRet = WideCharToMultiByte(CP_ACP, 0, strValue.c_str(), -1, sBuff, 102400, NULL, NULL);
if (iRet > 0) {
strRet = sBuff;
return TRUE;
}
return FALSE;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步