Char 轉成 TCHAR的辦法
// ANSI(char) to Unicode(TCHAR)
char* temp = "測試";
int nIndex = MultiByteToWideChar(CP_ACP, 0, temp , -1, NULL, 0);
TCHAR *pUnicode = new TCHAR[nIndex + 1];
MultiByteToWideChar(CP_ACP, 0, temp , -1, pUnicode, nIndex);


// Unicode(WCHAR) to ANSI(char)
TCHAR *pUnicode = _T("你好");
int nIndex = WideCharToMultiByte(CP_ACP, 0, pUnicode, -1, NULL, 0, NULL, NULL);
char *temp = new char[nIndex + 1];
WideCharToMultiByte(CP_ACP, 0, pUnicode, -1, temp , nIndex, NULL, NULL);
delete pAnsi;
arrow
arrow
    全站熱搜

    freestyler 發表在 痞客邦 留言(0) 人氣()