在字符转换的时候用 int MultiByteToWideChar( UINT CodePage, // code page DWORD dwFlags, // character-type options LPCSTR lpMultiByteStr, // address of string to map int cchMultiByte, // number of bytes in string LPWSTR lpWideCharStr, // address of wide-character buffer int cchWideChar // size of buffer ); LPCSTR -> LPWSTR
int MultiByteToWideChar(
UINT CodePage, // code page
DWORD dwFlags, // character-type options
LPCSTR lpMultiByteStr, // address of string to map
int cchMultiByte, // number of bytes in string
LPWSTR lpWideCharStr, // address of wide-character buffer
int cchWideChar // size of buffer
);
LPCSTR -> LPWSTR
我该怎么做?
see
http://www.codeproject.com/cpp/unicode.asp
WCHAR Unicode字符
PWSTR 指向Unicode字符串的指针
PCWSTR 指向一个恒定的Unicode字符串的指针
对应的ANSI数据类型为CHAR,LPSTR和LPCSTR。
ANSI/Unicode通用数据类型为TCHAR,PTSTR,LPCTSTR。
当然只定义了宏并不能实现自动的转换,他还需要一系列的字符定义支持。
TCHAR被定义为wchar_t
LPTSTR被定义为LPWSTR
在使用字符串常量的时候需要使用_TEXT(“MyStr”)来支持系统的自动转换
使用MultiByteToWideChar
没别的办法