遇到此问题第一时间在脑子里面联想到android下的strings.xml来做国际化,本文就仅仅针对解析xml来实现cocos2d-x的国际化解决乱码问题。

寻找解决方法的时候在cocos2d-x的cpp-tests文件里发现strings.xml。因此在事例源代码中发现此方法。

为了方便,我直接将C:\cocos2d-x-3.1\tests\cpp-tests\Resources\fonts的strings.xml文件复制到自己的fonts目录下。

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>chinese1</key>

<string>美好的一天</string>

<key>japanese</key>

<string>良い一日を</string>

<key>russian</key>

<string>Хорошего дня</string>

<key>spanish</key>

<string>Buen día</string>

</dict>

</plist>

xml的解析:

auto strings = FileUtils::getInstance()->getValueMapFromFile("fonts/strings.xml");

    std::string chinese  = strings["chinese1"].asString();

    std::string russian  = strings["russian"].asString();

    std::string spanish  = strings["spanish"].asString();

    std::string japanese = strings["japanese"].asString();

cocos2dx 3.0 显示中文及乱码解决方式的更多相关文章

  1. android sudio 执行的中文是乱码解决方式

    1.File-->Setings-->查找file encodings 例如以下图 2.将 IDE Encoding .Project Encoding.Default encoding ...

  2. cocos2d-x 3.0 final 中文显示

    cocos2d-x 3.0的中文显示非常easy,首先,你须要一个xml文件保存中文,还须要一个能显示中文的TTF文件 <?xml version="1.0" encodin ...

  3. 【python系列】python画报表(Chartkick、Flask)(附中文乱码解决方式)

    chartkick 能够画 javascript 报表, 并且比較美观.可是网上搜了下.非常难找到 python 版本号的,于是查了些资料,摸索了下. 对 Flask 也不非常熟悉,这里就仅仅抛砖引玉 ...

  4. MyEclipse中文注释乱码解决

    MyEclipse中文注释乱码解决 将别人的项目或JAVA文件导入到自己的Eclipse中时,常常会出现JAVA文件的中文注释变成乱码的情况,主要原因就是别人的IDE编码格式和自己的Eclipse编码 ...

  5. uploadify上传控件中文的乱码解决办法

    uploadify上传控件中文的乱码解决办法 网站用的gb2312的编码,用uploadify上传控件上传中文时在IE能部分成功,FF,Chrome则完全失败,查找了一天原因,结果发现是页面编码问题, ...

  6. hive中文字符乱码 解决方法【转】

    一.个人初始开发环境的基本情况以及Hive元数据库说明 ①hive的元数据库改成了mysql(安装完mysql之后也没有进行其它别的设置) ②hive-site.xml中设置元数据库对应的配置为  j ...

  7. Php显示中文时乱码

    <?php echo "你们好哈"; ?> 显示乱码,解决办法 <?php header("content-type:text/html; charse ...

  8. IDEA中文出现乱码解决(转)

    转自:http://lcl088005.iteye.com/blog/2284696 我是个idea的忠实用户,新公司的项目都是用eclipse做的,通过svn拉下代码后发现,注释的内容里,中文内容都 ...

  9. IDEA中文出现乱码解决

    转自:http://lcl088005.iteye.com/blog/2284696 我是个idea的忠实用户,新公司的项目都是用eclipse做的,通过svn拉下代码后发现,注释的内容里,中文内容都 ...

随机推荐

  1. ios NSRange

    Objective-C中判断字符串是否包含其他字符串 -(BOOL) hasPrefix:(NSString *) astring;检查字符串是否以astring开头:-(BOOL) hasSuffi ...

  2. C语言int *a 和int* a的写法

  3. DB2数据库在线备份还原

    DB2在线备份设置方法: 第一步:开启归档日志 db2 update db cfg for TEST_DB  using logretain on 第二步:重启数据库 第三步:进行一次离线备份 db2 ...

  4. k fit in Park Model

    software: Gnuplot input: area_averaged_axial_mean_velocity_TI_1.txt # One Rotor, front, eldad blade ...

  5. python中的函数的分类

    函数的种类 传参的基本要求 默认参数 *args 关键字参数 **kwargs 普通函数 带参数 默认参数 def text(a,b=2) print("haha") print( ...

  6. Milk(sort+结构体)

    Description Ignatius drinks milk everyday, now he is in the supermarket and he wants to choose a bot ...

  7. iptables工具

    http://www.linuxidc.com/Linux/2012-12/77074.htm iptables 指令 语法: iptables [-t table] command [match]  ...

  8. JavaScript高级程序设计中第2、3章中细节知识点

    第2章 1.<script src='script.js' type='text/javascript'></script>中,只要不包含defer和async属性,浏览器都会 ...

  9. Backspace doesn't delete inner html tags of a contenteditable DIV in Firefox

    https://bugzilla.mozilla.org/show_bug.cgi?id=439808 backspace键 在ff下不能使用  div contenteditable=true时

  10. python013 Python3 循环语句

    Python3 循环语句本章节将为大家介绍Python循环语句的使用.Python中的循环语句有 for 和 while.Python循环语句的控制结构图如下所示: while 循环Python中wh ...