【问题标题】:How to work with UTF-8 numeric encoded from Zend_Json in JS?如何在 JS 中使用 Zend_Json 编码的 UTF-8 数字?
【发布时间】:2011-09-17 10:26:43
【问题描述】:

我正在使用 Zend_Json(实际上,我正在使用带有自动 json 序列化的 ajaxContext),我需要发送以 Utf-8 编码的日文字符。

我从我的 ajax 请求中收到这样的数据:

{"comments":"\\u65e5\\u672c\\u6700"}

现在,我能用它做什么?将其“翻译”成我的 html 页面中的可读字符?

谢谢

【问题讨论】:

  • 尝试禁用魔术引号,Zend_Json(实际上是 json_decode)会自动将其转换为可在 html 页面中使用的有效 UTF-8 序列。
  • 您好,谢谢您的建议,但是:user@host:~$ php -i | grep "magic" magic_quotes_gpc => Off => Off magic_quotes_runtime => Off => Off magic_quotes_sybase => Off => Off

标签: php json utf-8 character-encoding


【解决方案1】:

您可以使用 jquery json 解析器来解码字符。

jQuery.parseJSON(response);

此函数将编码的字符转换为 html 中的可读字符。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-03
    • 2017-09-13
    • 2022-01-13
    • 2021-08-24
    • 1970-01-01
    • 2021-03-22
    相关资源
    最近更新 更多