使用plist文件,优点方便做多国语言支持~也不用去做编码转换
1.Resource目录下新建text.plist文件,内容格式如下
<?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>clickHurt</key> <string>点击伤害</string> </dict> </plist>
2.调用如下代码
std::string chineseStr; ValueMap data = FileUtils::getInstance()->getValueMapFromFile("text.plist"); chineseStr=data["clickHurt"].asString();