【Cocos2DX 】初窥门径(10)解决中文乱码

用资源文件保存字符串,格式UTF-8,这样读取xml文件,然后显示就不会乱码了。

这样做还有一个好处就是方便以后国际化。

xml文件:

<dict> 
	<key>Hello</key> 
	<string>Hi~可以正常显示中文了!</string> 
</dict>


显示:

	const char* Hello = ((CCString*)strings->objectForKey("Hello"))->m_sString.c_str();
	CCLabelTTF* pLabel1=CCLabelTTF::create(Hello,"Arial",24);
	pLabel1->setPosition(ccp(size.width/2,size.height/2));
	this->addChild(pLabel1);


效果:





转载请注明出处:http://blog.csdn.net/Vestigge



原文地址:https://www.cnblogs.com/xinyuyuanm/p/3022943.html