Rust
Rust
MIME Header Q and B Encoding and Decoding
See more Encryption Examples
Demonstrates how to Q and B encode/decode.Chilkat Rust Downloads
let sb = chilkat::StringBuilder::new();
let _ = sb.append("This is a test");
println!("{}", sb.get_encoded("B", "utf-8").unwrap_or_default());
// output is:
// =?utf-8?B?VGhpcyBpcyBhIHRlc3Q=?=
println!("{}", sb.get_encoded("Q", "iso-8859-1").unwrap_or_default());
// output is:
// =?utf-8?Q?This_is_a_test?=
let sb2 = chilkat::StringBuilder::new();
let _ = sb2.append("=?utf-8?B?VGhpcyBpcyBhIHRlc3Q=?=");
let _ = sb2.decode("B", "utf-8");
println!("{}", sb2.get_as_string().unwrap_or_default());
// output is:
// This is a test
sb2.clear();
let _ = sb2.append("=?utf-8?Q?This_is_a_test?=");
let _ = sb2.decode("Q", "utf-8");
println!("{}", sb2.get_as_string().unwrap_or_default());
// output is:
// This is a test
// "B" or "Q" will decode both B and Q.
sb2.clear();
let _ = sb2.append("=?utf-8?Q?This_is_a_test?= 123 =?utf-8?B?VGhpcyBpcyBhIHRlc3Q=?=");
let _ = sb2.decode("Q", "utf-8");
println!("{}", sb2.get_as_string().unwrap_or_default());
// output is:
// This is a test 123 This is a test