utf8轉unicode

  1. wstring Utf8ToUnicode(const string &utf8_str)
  2. {
  3.     int len;
  4.     len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)utf8_str.c_str(), -1, NULL,0);
  5.     WCHAR * wszUnicode = new WCHAR[len+1];
  6.     memset(wszUnicode, 0, len * 2 + 2);
  7.     MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)utf8_str.c_str(), -1, wszUnicode, len);

  8.     wstring unicodeWstring(wszUnicode);

  9.     delete wszUnicode;

  10.     return unicodeWstring;

  11. }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章