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

C++
#include <CkGzip.h>
#include <CkBinData.h>

void ChilkatSample(void)
    {
    bool success = false;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkGzip gzip;

    const char *gzipBase64 = "H4sIAAAAAAAE ... X6aZjXO3EwAA";

    CkBinData bd;
    success = bd.AppendEncoded(gzipBase64,"base64");

    success = gzip.UncompressBd(bd);
    if (success != true) {
        std::cout << gzip.lastErrorText() << "\r\n";
        return;
    }

    const char *strXml = bd.getString("utf-8");
    std::cout << "XML:" << "\r\n";
    std::cout << strXml << "\r\n";
    }