Cocos 在win32 平台上显示中文(仅实现win32)

Cocos 在win32 平台上显示中文(仅实现win32),第1张

概述测试显示 中文或者 其它平台已经判断显示的 可以借用这偷懒的方法 在cocos-x 3.2 ,vs2012 环境中运行的 在所使用的.h文件中私有添加   inline std::string WideByte2UTF8(const wstring& text) { int asciisize = ::WideCharToMultiByte(CP_UTF8, 0, text.c_str()

测试显示 中文或者 其它平台已经判断显示的 可以借用这偷懒的方法

在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)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1051399.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存