Sample code for 30+ languages & platforms
JavaScript

HTML Entity Encode and Decode in StringBuilder

Demonstrates HTML encoding and decoding the contents of a StringBuilder.
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 sb = new CkStringBuilder();

var s = "< é ü ç Ω Hello & World ✓ >";
sb.Append(s);

sb.Encode("html","utf-8");
console.log(sb.GetAsString());

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

// To decode:
sb.Decode("html","utf-8");
console.log(sb.GetAsString());

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