0

I want to convert all $nbsp , &iexcl with their character symbols. And Value which needs to be decode are inside an array .

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

Is there any solution for this??

I'm using html and javascript in my project. Answer i want to see:

    A[0].value = ¡res
prabin badyakar
  • 1,636
  • 2
  • 16
  • 24

2 Answers2

1

var a = $.parseHTML('  lalala »');
alert(a[0].textContent);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
Bitwise Creative
  • 4,035
  • 5
  • 27
  • 35
0
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();
dharmesh
  • 308
  • 1
  • 13
  • 1
    If you could please edit your answer and explain what the code you're showing does, and why/how that code answers the question, it could really help. – Lea Cohen Feb 10 '15 at 06:38