Sample code for 30+ languages & platforms
Rust

Ungzip Base64 String

See more Gzip Examples

Suppose you have a gzip in base64 representation that contains a text file, such as XML. This example shows how to decompress and access the string.

Chilkat Rust Downloads

Rust

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let gzip = chilkat::Gzip::new();

let gzip_base64 = "H4sIAAAAAAAE ... X6aZjXO3EwAA".to_string();

let bd = chilkat::BinData::new();
let _ = bd.append_encoded(&gzip_base64, "base64").is_ok();

if gzip.uncompress_bd(&bd).is_err() {
    println!("{}", gzip.last_error_text());
    return;
}

let str_xml = bd.get_string("utf-8").unwrap_or_default();
println!("XML:");
println!("{}", str_xml);