在解决了中文显示乱码的问题之后,仍然有很多的问题需要我们解决。
char * G2U(const char* gb2312){
int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0);
wchar_t* wstr = new wchar_t[len+1];
memset(wstr, 0, len+1);
MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len);
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
char* str = new char[len+1];
memset(str, 0, len+1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
if(wstr) delete[] wstr;
return str;
}
这是win32的解决方案其实网上还有很多关于win32的中文解决方案。
还有一种方案是直接修改VS2012(我用的是vs2012)的编码方式
选择你模拟器支持的编码格式,编码时直接输入中文即可