Sample code for 30+ languages & platforms
PureBasic

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 PureBasic Downloads

PureBasic
IncludeFile "CkGzip.pb"
IncludeFile "CkBinData.pb"

Procedure ChilkatExample()

    success.i = 0

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

    gzip.i = CkGzip::ckCreate()
    If gzip.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    gzipBase64.s = "H4sIAAAAAAAE ... X6aZjXO3EwAA"

    bd.i = CkBinData::ckCreate()
    If bd.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkBinData::ckAppendEncoded(bd,gzipBase64,"base64")

    success = CkGzip::ckUncompressBd(gzip,bd)
    If success <> 1
        Debug CkGzip::ckLastErrorText(gzip)
        CkGzip::ckDispose(gzip)
        CkBinData::ckDispose(bd)
        ProcedureReturn
    EndIf

    strXml.s = CkBinData::ckGetString(bd,"utf-8")
    Debug "XML:"
    Debug strXml


    CkGzip::ckDispose(gzip)
    CkBinData::ckDispose(bd)


    ProcedureReturn
EndProcedure