JavaScript
JavaScript
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.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat
v11.4.0 or greater.
var success = false;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var gzip = new CkGzip();
var gzipBase64 = "H4sIAAAAAAAE ... X6aZjXO3EwAA";
var bd = new CkBinData();
success = bd.AppendEncoded(gzipBase64,"base64");
success = gzip.UncompressBd(bd);
if (success !== true) {
console.log(gzip.LastErrorText);
return;
}
var strXml = bd.GetString("utf-8");
console.log("XML:");
console.log(strXml);