Sample code for 30+ languages & platforms
Unicode 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 Unicode C Downloads

Unicode C
#include <C_CkGzipW.h>
#include <C_CkBinDataW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkGzipW gzip;
    const wchar_t *gzipBase64;
    HCkBinDataW bd;
    const wchar_t *strXml;

    success = FALSE;

    // 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);

    }