Sample code for 30+ languages & platforms
Chilkat2-Python

HTML Encoding

Demonstrates HTML encoding and decoding.

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import chilkat2

crypt = chilkat2.Crypt2()

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

htmlEncoded = crypt.EncodeString(s,"utf-8","html")
print(htmlEncoded)

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

# To decode:
s = crypt.DecodeString(htmlEncoded,"utf-8","html")
print(s)

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