char* 转化为 WCHAR* 的方法

WCHAR* ctowc( char *str ) { WCHAR* wstr = new WCHAR[2 * strlen(str) + 2]; if( !wstr ) return NULL; MultiByteToWideChar( CP_ACP, 0, str, -1, wstr, 2 * (int )strlen( str ) + 2 ); return wstr; } int main() { char *str = "测试字符串"; WCHAR *wstr = ctowc( str ); return 0; }

你可能感兴趣的:(测试,null)