2

Possible Duplicate:
How to decode HTML entities using jQuery?
HtmlSpecialChars equivalent in Javascript?

I need to convert with escaped htmlspecialchars to a valid HTML code, for example:

<p>Text here</p>

should be displayed in the browser like

Text here

What is the right way to do that?

Thanks in advance, Ivan.

Community
  • 1
  • 1
Ivan Gromov
  • 4,195
  • 9
  • 41
  • 57
  • @anonymousdownvotingislame Side note: I totally agree with your name – Oliver Spryn Aug 07 '12 at 15:07
  • stepped over this searching to savely replace { into "TEXT" (not HTML!) with jquery... finaly confused by the other topic, i figured this out for me: – René W. Jun 07 '17 at 12:39
  • var htmlRegExConversion = new RegExp("(\\\\d+);"); while (htmlRegExConversion.test(anyText)) anyText = anyText.replace(htmlRegExConversion, function (e) { return String.fromCharCode(e.substring(2,e.length-1)*1); }); so this is not an answer for the question but maybe somebody as well hits this post – René W. Jun 07 '17 at 12:47

2 Answers2

2

How to decode HTML entities using jQuery? and jQuery .appendTo method worked for me.

Community
  • 1
  • 1
Ivan Gromov
  • 4,195
  • 9
  • 41
  • 57
1

Try the PHP.JS function to perform this action. Their examples solve exactly the question you are asking:

http://phpjs.org/functions/htmlspecialchars_decode:427

Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195
  • the question never mentions php. what if we are not using php – Neville Nazerane May 29 '14 at 07:32
  • 3
    @NevilleNazerane I didn't mention PHP, either. I said PHP.JS, which is a library which includes JavaScript implementations of many of PHP's built-in functions. It is purely a JavaScript implementation and is totally independent and unrelated to PHP. – Oliver Spryn May 29 '14 at 14:08