大佬教程收集整理的这篇文章主要介绍了Cocos 在win32 平台上显示中文(仅实现win32),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
测试显示 中文或者 其它平台已经判断显示的 可以借用这偷懒的方法
在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);
以上是大佬教程为你收集整理的Cocos 在win32 平台上显示中文(仅实现win32)全部内容,希望文章能够帮你解决Cocos 在win32 平台上显示中文(仅实现win32)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。