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

HTML Encoding

Demonstrates HTML encoding and decoding.

Chilkat Rust Downloads

Rust
let crypt = chilkat::Crypt2::new();

let mut s = "< é ü ç Ω Hello & World ✓ >".to_string();

let html_encoded = crypt.encode_string(&s, "utf-8", "html").unwrap_or_default();
println!("{}", html_encoded);

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

// To decode:
s = crypt.decode_string(&html_encoded, "utf-8", "html").unwrap_or_default();
println!("{}", s);

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