(C) 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.
#include <C_CkGzip.h>
#include <C_CkBinData.h>
void ChilkatSample(void)
{
HCkGzip gzip;
const char *gzipBase64;
HCkBinData bd;
BOOL success;
const char *strXml;
// 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);
}
|