我有一个字符串如下:
"\u041a\u043b\u0443\u0431 Test";
它是由json_encode()解码的,原始字符串是俄语中的"Клуб Test"。
当我将其放到js中时,
alert("\u041a\u043b\u0443\u0431 Test");
我能够正确地显示它,就像在屏幕上一样。因此,js以某种方式正确地将其解码为正常视图。
问题是我该如何在php中做同样的事情,是否有任何内置方法?
答案是: $json_in = '{"testKey":"\u041a\u043b\u0443\u0431 Test"}'; $json_out = json_decode($json_in, true); 或者 将 "\u041a\u043b\u0443\u0431" 转换为 "Клуб" ,然后执行html_entity_decode($str, null, 'UTF-8');
答案是: $json_in = '{"testKey":"\u041a\u043b\u0443\u0431 Test"}'; $json_out = json_decode($json_in, true); 或者 将 "\u041a\u043b\u0443\u0431" 转换为 "Клуб" ,然后执行html_entity_decode($str, null, 'UTF-8');