Sample code for 30+ languages & platforms
JavaScript

HTML Encoding

Demonstrates HTML encoding and decoding.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var crypt = new CkCrypt2();

var s = "< é ü ç Ω Hello & World ✓ >";

var htmlEncoded = crypt.EncodeString(s,"utf-8","html");
console.log(htmlEncoded);

// Output:
// < &eacute; &uuml; &ccedil; &ohm; Hello & World &check; >

// To decode:
s = crypt.DecodeString(htmlEncoded,"utf-8","html");
console.log(s);

// Output:
// < é ü ç Ω Hello & World ✓ >