Sample code for 30+ languages & platforms
Rust

StringBuilder GetEncoded

Demonstrates the Chilkat StringBuilder GetEncoded method.

Chilkat Rust Downloads

Rust
let s = "The quick brown fox jumps over the lazy dog".to_string();

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

let _ = sb.append(&s);

// output: The quick brown fox jumps over the lazy dog
println!("{}", sb.get_as_string().unwrap_or_default());

// Get the string encoded to base64, without changing the contents of sb.
// output: VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==
println!("{}", sb.get_encoded("base64", "utf-8").unwrap_or_default());

// The contents of sb are not changed..
// output: The quick brown fox jumps over the lazy dog
println!("{}", sb.get_as_string().unwrap_or_default());