9miao / CrossApp

Cross-Platform Mobile APP Development Engine
MIT License
835 stars 421 forks source link

Win32下UTF8输入为char*时为乱码 #119

Open Leadrive opened 8 years ago

Leadrive commented 8 years ago
CAAlertView *alertView = CAAlertView::createWithText(UTF8("提示"), UTF8("登陆成功"), UTF8("确定"), NULL);

这句在ios下是正常显示的。 如果改成char char\ sTemp = "登陆成功"; std::wstring ws = utf8_to_unicode(sTemp);

CAAlertView *alertView = CAAlertView::createWithText(UTF8("提示"), unicode_to_utf8(ws.c_str()).c_str(), UTF8("确定"), NULL);

在ios下也是成功的。

但是在win32下却是乱码,原因是 _utf8_to_unicode 把四个汉字处理成了8个字节,在ios下是4个字节。建议在win32下,改用mbstowcs_s

wjain commented 7 years ago

看一下文件编码对不对,改成utf-8 bom的试试