Perl
Perl
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 Perl Downloads
use strict;
use warnings;
use Chilkat2;
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
my $gzip = Chilkat2::Gzip->new;
my $gzipBase64 = 'H4sIAAAAAAAE ... X6aZjXO3EwAA';
my $bd = Chilkat2::BinData->new;
my $success = $bd->AppendEncoded($gzipBase64, 'base64');
$success = $gzip->UncompressBd($bd);
if (!$success) {
print $gzip->LastErrorText, "\n";
exit;
}
my $strXml = $bd->GetString('utf-8');
print "XML:\n";
print $strXml, "\n";