c++ Utf8和Unicode相互转换

int Utf8_To_Unicode(string strSrc, wstring& strRet)
{
  wchar_t wBuff[102400] = { 0 };
  int iRet = MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, wBuff, 102400);
  if (iRet > 0) {
    strRet = wBuff;
    return TRUE;
  }
  return FALSE;
}

int Unicode_To_Uft8(wstring wstrValue, string& strRet)
{
  CHAR sBuff[102400] = { 0 };

  int iRet = WideCharToMultiByte(CP_UTF8, 0, wstrValue.c_str(), -1, sBuff, 102400, NULL, NULL);
  if (iRet > 0) {
    strRet = sBuff;
    return TRUE;
  }
  return FALSE;
}

原文地址:https://www.cnblogs.com/longma8586/p/13929134.html