(PHP ActiveX) Ungzip Base64 String
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.
<?php
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.Gzip')
$gzip = new COM("Chilkat.Gzip");
$gzipBase64 = 'H4sIAAAAAAAE ... X6aZjXO3EwAA';
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.BinData')
$bd = new COM("Chilkat.BinData");
$success = $bd->AppendEncoded($gzipBase64,'base64');
$success = $gzip->UncompressBd($bd);
if ($success != 1) {
print $gzip->LastErrorText . "\n";
exit;
}
$strXml = $bd->getString('utf-8');
print 'XML:' . "\n";
print $strXml . "\n";
?>
|