How to Encode/Decode HTML Entities?

Just starting out? Need help? Post your questions and find answers here.
ehbarba
Posts: 31
Joined: Thu Mar 29, 2018 2:20 am

How to Encode/Decode HTML Entities?

Post by ehbarba »

Is there a way to Encode/Decode HTML Entities?

Greetings

Ezequiel
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: How to Encode/Decode HTML Entities?

Post 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
ehbarba
Posts: 31
Joined: Thu Mar 29, 2018 2:20 am

Re: How to Encode/Decode HTML Entities?

Post by ehbarba »

Thank you Peter.

It works great.

Ezequiel
Post Reply