C
C
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 C Downloads
#include <C_CkGzip.h>
#include <C_CkBinData.h>
void ChilkatSample(void)
{
BOOL success;
HCkGzip gzip;
const char *gzipBase64;
HCkBinData bd;
const char *strXml;
success = FALSE;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
gzip = CkGzip_Create();
gzipBase64 = "H4sIAAAAAAAE ... X6aZjXO3EwAA";
bd = CkBinData_Create();
success = CkBinData_AppendEncoded(bd,gzipBase64,"base64");
success = CkGzip_UncompressBd(gzip,bd);
if (success != TRUE) {
printf("%s\n",CkGzip_lastErrorText(gzip));
CkGzip_Dispose(gzip);
CkBinData_Dispose(bd);
return;
}
strXml = CkBinData_getString(bd,"utf-8");
printf("XML:\n");
printf("%s\n",strXml);
CkGzip_Dispose(gzip);
CkBinData_Dispose(bd);
}