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

HTML Entity Encode and Decode in StringBuilder

Demonstrates HTML encoding and decoding the contents of a StringBuilder.

Chilkat Rust Downloads

Rust
let sb = chilkat::StringBuilder::new();

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

let _ = sb.encode("html", "utf-8");
println!("{}", sb.get_as_string().unwrap_or_default());

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

// To decode:
let _ = sb.decode("html", "utf-8");
println!("{}", sb.get_as_string().unwrap_or_default());

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