Page 1 of 1

How to Encode/Decode HTML Entities?

Posted: Mon May 07, 2018 4:41 pm
by ehbarba
Is there a way to Encode/Decode HTML Entities?

Greetings

Ezequiel

Re: How to Encode/Decode HTML Entities?

Posted: Mon May 07, 2018 5:13 pm
by Peter

Code: Select all

Procedure.s EncodeHTML(HTML.s)
  ! return $('<div />').text(v_html).html();
EndProcedure

Procedure.s DecodeHTML(Text.s)
  ! return $('<div />').html(v_text).text();
EndProcedure

Debug EncodeHTML("Some text with <div>html</div>")
Debug DecodeHTML("Some text with <div>html</div>")
(Inspired by: https://coderwall.com/p/jt7ysq/encode-s ... via-jquery)

Greetings ... Peter

Re: How to Encode/Decode HTML Entities?

Posted: Mon May 07, 2018 6:21 pm
by ehbarba
Thank you Peter.

It works great.

Ezequiel