多字節轉Unicode
四步:
Step1
#include <iostream> #include "windows.h" using namespace std; void ANSIToUnicode(const char str[]) { //獲取持轉換的字符個數 int unicodeLen = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL,
0 ); //分配寬字符內存 wchar_t * pUnicode = new wchar_t[unicodeLen]; //多字節->寬字符 MultiByteToWideChar( CP_ACP, 0, str, -1, pUnicode, unicodeLen ); /* ...對生成結果進行處理 ...*/ delete []pUnicode; } int main() { char msg[]="M11中文網"; ANSIToUnicode(msg); return 0; }