测试显示 中文或者 其它平台已经判断显示的 可以借用这偷懒的方法
在cocos-x 3.2,vs2012 环境中运行的
在所使用的.h文件中私有添加
inline std::string WideByte2UTF8(const wstring& text) { int asciisize = ::WideCharToMultiByte(CP_UTF8,text.c_str(),text.size(),NULL,NULL); if (asciisize == ERROR_NO_UNICODE_TRANSLATION || asciisize == 0) { return string(); } char* resultstring = new char[asciisize]; int convresult = ::WideCharToMultiByte(CP_UTF8,resultstring,asciisize,NULL); if (convresult != asciisize) { return string(); } std::string buffer(resultstring,convresult); delete[] resultstring; return buffer; }
在cpp中调用
std::string str = ""; str = WideByte2UTF8(L"你好世界"); Label* label = Label::createWithSystemFont(str.c_str(),"Arial",20); label->setColor(Color3B::RED); label->setPosition(200,200); this->addChild(label);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。