Sample code for 30+ languages & platforms
Lua Requires Chilkat v11.1.0+

HTML Entity Encode and Decode in StringBuilder

Demonstrates HTML encoding and decoding the contents of a StringBuilder.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local sb = chilkat.StringBuilder.new()

local s = "< é ü ç Ω Hello & World ✓ >"
sb:append(s)

sb:encode("html", "utf-8")
print(sb:get_as_string())

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

-- To decode:
sb:decode("html", "utf-8")
print(sb:get_as_string())

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