Sample code for 30+ languages & platforms
CkPython

HTML Entity Encode and Decode in StringBuilder

Demonstrates HTML encoding and decoding the contents of a StringBuilder.

Chilkat CkPython Downloads

CkPython
import chilkat

sb = chilkat.CkStringBuilder()

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

sb.Encode("html","utf-8")
print(sb.getAsString())

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

# To decode:
sb.Decode("html","utf-8")
print(sb.getAsString())

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