Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Leadrive opened this issue Sep 27, 2016 · 1 comment
Open

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

Leadrive opened this issue Sep 27, 2016 · 1 comment

Comments

@Leadrive
Copy link

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
Copy link

wjain commented Oct 27, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants