Sample code for 30+ languages & platforms
Rust

Appending Strings to BinData

Demonstrates appending strings to a BinData..

Chilkat Rust Downloads

Rust
let bin_data1 = chilkat::BinData::new();

// Append a string using a 1-byte per char encoding
let _ = bin_data1.append_string("This is a test", "windows-1252");
println!("{}", bin_data1.get_encoded("hex").unwrap_or_default());
// The bytes contained within the binData1 (in hex) are: 54,68,69,73,20,69, ...

let bin_data2 = chilkat::BinData::new();

// Append a string using a 2-byte per char encoding
let _ = bin_data2.append_string("This is a test", "utf-16");
println!("{}", bin_data2.get_encoded("hex").unwrap_or_default());
// The bytes contained within the binData2 (in hex) are: 54,00,68,00,69,00,73,00,20,00,69,00, ...