【Cocos2D-X 】初窥门径(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



posted @ 2013-04-15 21:25  xinyuyuanm  阅读(159)  评论(0编辑  收藏  举报