(Unicode 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_CkGzipW.h>
#include <C_CkBinDataW.h>
void ChilkatSample(void)
{
HCkGzipW gzip;
const wchar_t *gzipBase64;
HCkBinDataW bd;
BOOL success;
const wchar_t *strXml;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
gzip = CkGzipW_Create();
gzipBase64 = L"H4sIAAAAAAAE ... X6aZjXO3EwAA";
bd = CkBinDataW_Create();
success = CkBinDataW_AppendEncoded(bd,gzipBase64,L"base64");
success = CkGzipW_UncompressBd(gzip,bd);
if (success != TRUE) {
wprintf(L"%s\n",CkGzipW_lastErrorText(gzip));
CkGzipW_Dispose(gzip);
CkBinDataW_Dispose(bd);
return;
}
strXml = CkBinDataW_getString(bd,L"utf-8");
wprintf(L"XML:\n");
wprintf(L"%s\n",strXml);
CkGzipW_Dispose(gzip);
CkBinDataW_Dispose(bd);
}
|