Rust
Rust
Example: Crypt2.EncodeString method
Demonstrates how to call the EncodeString method.Chilkat Rust Downloads
let crypt = chilkat::Crypt2::new();
let mut s = "Hello World".to_string();
println!("{}", crypt.encode_string(&s, "utf-8", "hex").unwrap_or_default());
// Output: 48656C6C6F20576F726C64
println!("{}", crypt.encode_string(&s, "utf-16", "hex").unwrap_or_default());
// Output: 480065006C006C006F00200057006F0072006C006400
println!("{}", crypt.encode_string(&s, "utf-8", "base64").unwrap_or_default());
// Output: SGVsbG8gV29ybGQ=
s = "électricité".to_string();
println!("{}", crypt.encode_string(&s, "utf-8", "hex").unwrap_or_default());
// Output: C3A96C6563747269636974C3A9
println!("{}", crypt.encode_string(&s, "windows-1252", "hex").unwrap_or_default());
// Output: E96C6563747269636974E9
println!("{}", crypt.encode_string(&s, "windows-1252", "hex_lower").unwrap_or_default());
// Output: e96c6563747269636974e9
println!("{}", crypt.encode_string(&s, "utf-8", "url").unwrap_or_default());
// Output: %C3%A9lectricit%C3%A9