// 多字节字符转换为宽字符
方法一(使用API):
string str;
str = "hello";
WCHAR szwChar[256];
int nChar = MultiByteToWideChar (CP_ACP, 0, str.c_str (), -1, szwChar, 256);
使用szwChar即可。
方法二(使用CString类):
CStringW strW ("hello");
直接使用strW吧!
// 宽字符转换为多字节字符
方法一(使用API):
wstring wstr;
wstr = L"hello";
int cb;
char sz[64];
cb = WideCharToMultiByte (CP_ACP, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL);
WideCharToMultiByte (CP_ACP, 0, wstr.c_str(), -1, sz, cb, NULL, NULL);
使用sz即可。
方法二(使用CString类):
CStringA strA (L"hello");
直接使用strA吧!