Sample code for 30+ languages & platforms
DataFlex

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

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoGzip
    String sGzipBase64
    Variant vBd
    Handle hoBd
    String sStrXml
    String sTemp1

    Move False To iSuccess

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

    Get Create (RefClass(cComChilkatGzip)) To hoGzip
    If (Not(IsComObjectCreated(hoGzip))) Begin
        Send CreateComObject of hoGzip
    End

    Move "H4sIAAAAAAAE ... X6aZjXO3EwAA" To sGzipBase64

    Get Create (RefClass(cComChilkatBinData)) To hoBd
    If (Not(IsComObjectCreated(hoBd))) Begin
        Send CreateComObject of hoBd
    End
    Get ComAppendEncoded Of hoBd sGzipBase64 "base64" To iSuccess

    Get pvComObject of hoBd to vBd
    Get ComUncompressBd Of hoGzip vBd To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoGzip To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComGetString Of hoBd "utf-8" To sStrXml
    Showln "XML:"
    Showln sStrXml


End_Procedure