获取“名称”:“\\\ח\\\ב\\\ר\\\ה”非英语 [英] JSON getting "name":"\u05d7\u05d1\u05e8\u05d4" for non-English
问题描述
我收到了Ajax从PHP返回的JSON json_encode
我有一个希伯来字符变成\\\ח\\ \\ u05d1\\\ר\\\ה
我该怎么把它们转回希伯来语?
(数据库编码为UTF8,当调用PHP文件希伯来语正确显示)
I am getting a JSON returned by Ajax from PHP json_encode
I have a Hebrew characters that turned into "\u05d7\u05d1\u05e8\u05d4"
How can I turn them back into Hebrew?
(The DB is encoded UTF8 and when calling the PHP file the Hebrew is displayed correctly)
推荐答案
正如Quentin所指出的,这是正确的。 \uXXXX
是unicode字符的正确转义序列。事实上,如果你输入firebug控制台,它会提示你חברה
。这样看起来似乎是希伯来语,虽然我不知道是否正确。
As Quentin pointed out, this is correct. \uXXXX
is a correct escape sequence for a unicode character. In fact, if you type in into the firebug console, it will prompt you "חברה"
. That does look hebrew to me, although I can't tell whether it's correct.
因此,在解析了您收到的数据后(使用 eval
或 JSON.parse
)角色应该自动取消转义。
Therefore after parsing the data you received (either with eval
or JSON.parse
) the character should be unescaped automatically.
这篇关于获取“名称”:“\\\ח\\\ב\\\ר\\\ה”非英语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!