![]() |
#2
纯蓝之刃2020-10-26 15:29
|
但 大端 是不行的,直接用会乱码,那该如何呢???
(我的土办法是 多次 读取 两字节 然后 交换 变成 小端,最后再用 WideCharToMultiByte 转 ANSI )
网上这个函数:

char * UnicodeToANSI( const wchar_t* str )
{
char* result;
int textlen;
textlen = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
result =(char *)malloc((textlen+1)*sizeof(char));
memset( result, 0, sizeof(char) * ( textlen + 1 ) );
WideCharToMultiByte( CP_ACP, 0, str, -1, result, textlen, NULL, NULL );
return result;
}
[此贴子已经被作者于2020-10-26 15:24编辑过]