Swift
Swift
HTML Encoding
Demonstrates HTML encoding and decoding.Chilkat Swift Downloads
func chilkatTest() {
let crypt = CkoCrypt2()!
var s: String? = "< é ü ç Ω Hello & World ✓ >"
var htmlEncoded: String? = crypt.encodeString(inStr: s, charset: "utf-8", encoding: "html")
print("\(htmlEncoded!)")
// Output:
// < é ü ç Ω Hello & World ✓ >
// To decode:
s = crypt.decodeString(inStr: htmlEncoded, charset: "utf-8", encoding: "html")
print("\(s!)")
// Output:
// < é ü ç Ω Hello & World ✓ >
}