Html解码器和编码器



我想转换所有$nbsp,&iexcl及其字符符号。和需要解码的值在一个数组中。

A[
{ id:1 , value:"¡resu"},
{id:1 , value:" hi"}]

有什么解决办法吗??

我在我的项目中使用html和javascript。我想看到的答案:

    A[0].value = ¡res

var a = $.parseHTML('  lalala »');
alert(a[0].textContent);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

String.prototype.decodeEscapeSequence = function() {
    return this.replace(/\x([0-9A-Fa-f]{2})/g, function() {
        return String.fromCharCode(parseInt(arguments[1], 16));
    });
};

var decodedString = str.decodeEscapeSequence();

相关内容

最新更新