我正在开发多语言应用程序,我们使用utf8_genral_ci以多语言存储信息。 信息在数据库中正确存储,但json编码为我提供了不正确的格式化数据。
这些是我从服务器获得的
{"Result":[{"id":"1","name":"\u0939\u093f\u0902\u0926\u0940","admin_id":"29","active":"yes","time":"2013-06-04 03:26:47"},{"id":"2","name":"\u4e2d\u570b\u7684","admin_id":"29","active":"yes","time":"2013-06-04 03:27:11"},{"id":"3","name":"fran\u00e7ais","admin_id":"29","active":"yes","time":"2013-06-04 03:27:34"}]}
虽然我想在这些合成中转换/保存结果
{
"Result": [
{
"id": "1",
"name": "हिंदी",
"admin_id": "29",
"active": "yes",
"time": "2013-06-04 03:26:47"
},
{
"id": "2",
"name": "中國的",
"admin_id": "29",
"active": "yes",
"time": "2013-06-04 03:27:11"
},
{
"id": "3",
"name": "français",
"admin_id": "29",
"active": "yes",
"time": "2013-06-04 03:27:34"
}
]
}
提前致谢。
答案 0 :(得分:1)
从字符串的外观来看,unicode不会在字符串中编码为UTF8,而是作为其表示形式。也就是说,如果我创建一个静态字符串,我使用\ u ...,但编译器会看到并创建UTF8。当你在从服务器收到的字符串中看到\ u ...时,它意味着它是使用\ \ u ...创建的 - \被转义了。我的猜测是你需要处理字符串,寻找\ uxxxx,并用那个代码点的真实UTF8替换它们。