简体   繁体   English

json_encode Unicode转义序列无法在javascript中显示

[英]json_encode unicode escape sequences cannot display in javascript

json_encode(array($myarray1,$myarray2)) json_encode(阵列($ myarray1,$ myarray2))

on php contains unicode escape sequences like 在PHP上包含Unicode转义序列,如

[{
"Panelbuilder 32":
    [{
        "topic_id":"34",
        "forum_id":"6",
        "topic_title": "Panelbuilder 32",
        "topic_poster":"1",
        "topic_time":"1189740810",
        "topic_last_post_id":"124",
        "topic_last_poster_id":"1",
        "topic_last_poster_name":"vvv",
        "topic_last_post_time":"1189740810",
        "topic_last_post_subject":"Panelbuilder 32",
        "topic_last_view_time":"1436511928",
        "topic_replies":"0",
        "topic_replies_real":"0",
        "topic_views":"2463",
        "topic_attachment":"0",
        "topic_reported":"0",
        "topic_first_post_id":"124",
        "topic_first_poster_name":"vvv"
    }]
}, {
"124":
    [{
        "post_id":"124",
        "topic_id":"34",
        "forum_id":"6",
        "poster_id":"1",
        "poster_ip":"192.44.136.113",
        "post_time":"1189740810",
        "post_approved":"1",
        "post_reported":"0",
        "post_username":"vvv",
        "post_subject":"Panelbuilder 32",
        "post_text":"\u0e23\u0e03\u0e22\u0e04\u0e23\u0083\u0e23\u0081\u0e23\u0095\u0e22\u0e04\u0e23\u0087\u0e23\u0092\u0e23\u0081\u0e22\u0e0a\u0e23\u0093\u0e22\u0e19\u0e23\u0092\u0e22\u0e0d\u0e23\u0e03\u0e22\u0e19\u0e22\u0e01\u0e23\u0092\u0e23\u0083\u0e23\u0e03\u0e22\u0e0a\u0e23\u0e09\u0e23\u0e02\u0e22\u0e1b\u0e23\u0083\u0e23\u0e01\u0e22\u0e01\u0e23\u0083\u0e23\u0081 Panelbuilder 32 \u0e22\u0e02\u0e23\u008d\u0e22\u0e07  AB",
        "post_attachment":"0",
        "post_edit_time":"0",
        "topic_poster":"1",
        "topic_time":"1189740810",
        "topic_last_post_id":"124",
        "topic_last_poster_id":"1",
        "topic_last_poster_name":"vvv",
        "topic_last_post_time":"1189740810",
        "topic_last_post_subject":"Panelbuilder 32",
        "topic_last_view_time":"1436511928",
        "topic_replies":"0",
        "topic_replies_real":"0",
        "topic_views":"2463",
        "topic_attachment":"0",
        "topic_reported":"0",
        "topic_first_post_id":"124",
        "topic_first_poster_name":"vvv"
    }]
}]

These unicode sequences displays in javascript like this /ue023 (backslash converted to forward slash) and cannot displays as characters.I need to display these characters on my phonegap application. 这些unicode序列在javascript中显示为/ue023 (将反斜杠转换为正斜杠),并且无法显示为字符。我需要在我的phonegap应用程序中显示这些字符。 Is there any solution ? 有什么解决办法吗?

As you explained your using JSON.parse heres my solution: 正如您解释使用JSON.parse的方法一样,这是我的解决方案:

var str = JSON.parse(data);
str.replace(/\//g, "\\");

Obviously however you get your field you will need to update the code above, eg 显然,无论如何,您需要更新上面的代码,例如

var new_data = str[1][124][0].post_text.replace(/\//g, "\\");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM