0

I'm trying to decode a string and insert it into a new string, but it just won't work. I tried unescape and decodeURIComponent.

What am I doing wrong? Here is a plunker.

This is the code:

var str = "2015         :           alle";
alert(unescape(str));

I prefer to do it in AngularJS.

8
  • Did you check this stackoverflow.com/questions/4292914/… ? Commented Dec 2, 2015 at 14:17
  • 1
    Those are HTML entities, not URL encoding. All   are just no-break spaces. And the : is a :. Commented Dec 2, 2015 at 14:18
  • Oh ok thanks! I'll go and search for HTML entities decoding. Commented Dec 2, 2015 at 14:19
  • unescape works on hex numbers, e.g. %A7. you don't have hex digits, you have html entities: stackoverflow.com/questions/1147359/… Commented Dec 2, 2015 at 14:19
  • You could decode it with str.replace(/&#(\d+);/g, function(t, c){return String.fromCharCode(c);});. Commented Dec 2, 2015 at 14:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.