无法对存储在数组中的字符串使用“unes​​cape()”

时间:2017-05-26 18:07:02

标签: javascript jquery escaping

我有大约7000行带有unicode符号的文本例如:7123 \ud83d\ude4c\ud83d\ude4fQue Deus nos defenda das ruindades calmas e dos odios q sorriem \ud83d\ude07\ud83d\udc4a

当我直接打印字符串时,我得到符号,

$("#filteredContent").text(unescape("7123   \ud83d\ude4c\ud83d\ude4fQue Deus nos defenda das ruindades calmas e dos odios q sorriem \ud83d\ude07\ud83d\udc4a"));

输出:7123 Que Deus nos defenda das ruindades calmas e dos odios q sorriem

但是,如果我将所有字符串插入数组并尝试打印它们,那么我就看不到符号了,

        var main = $("#mainContent").text();
        var arr = main.split("\n");
        var index = 0;
        for(var i=0;i<arr.length;i++){
                $("#filteredContent").append(unescape(arr[i].trim()));
        }

Output: 7123 \ud83d\ude4c\ud83d\ude4fQue Deus nos defenda das ruindades calmas e dos odios q sorriem \ud83d\ude07\ud83d\udc4a

JSFiddle:https://jsfiddle.net/rcjydwr7/

0 个答案:

没有答案