//UNICODE字符串轉換為ansi字符串
PTCHAR ptszText = TEXT("UNICODE字符串轉換為ansi字符串!");
int cbMultiByte = WideCharToMultiByte(CP_ACP, 0, ptszText, -1, NULL, 0, NULL, NULL);
char *pszText = NULL;
pszText = new char[cbMultiByte];
WideCharToMultiByte(CP_ACP, 0, ptszText, -1, pszText, cbMultiByte, NULL, NULL);
delete[] pszText;
//Cstring轉ansii
CString csText = L"UNICODE字符串轉換為ansi字符串!";
int iByte = WideCharToMultiByte(CP_ACP, 0, csText, -1, NULL, 0, NULL, NULL);
char *chText = NULL;
chText = new char[iByte];
WideCharToMultiByte(CP_ACP, 0, csText, -1, chText, cbMultiByte, NULL, NULL);
delete[] pszText;
測試環境:VS2015 MFC