![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) Compress Text Feed to BinaryThis example receives incoming text data in chunks, compresses as a stream, and accumulates the compressed binary data. Note: This example requires Chilkat v11.0.0 or greater.
Local $bSuccess = False ; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oBdCompressed = ObjCreate("Chilkat.BinData") $oCompress = ObjCreate("Chilkat.Compression") $oCompress.Algorithm = "deflate" $oCompress.Charset = "utf-8" $oSbUncompressedChunk = ObjCreate("Chilkat.StringBuilder") $oCompress.FirstChunk = True $oCompress.LastChunk = False Local $i For $i = 0 To 24 If ($i = 24) Then $oCompress.LastChunk = True EndIf $oSbUncompressedChunk.Clear $oSbUncompressedChunk.AppendInt($i) $oSbUncompressedChunk.Append(": This is a line of data to be compressed..." & @CRLF) $oCompress.CompressSb($oSbUncompressedChunk,$oBdCompressed) $oCompress.FirstChunk = False Next ; Show the compressed data in hex format: ConsoleWrite("The hex encoded compressed text:" & @CRLF) ConsoleWrite($oBdCompressed.GetEncoded("hex") & @CRLF) ; Now decompress in one call. It is important to set both FirstChunk and LastChunk = True $oBdDecompressed = ObjCreate("Chilkat.BinData") $oCompress.FirstChunk = True $oCompress.LastChunk = True $bSuccess = $oCompress.DecompressBd2($oBdCompressed,$oBdDecompressed) If ($bSuccess = False) Then ConsoleWrite($oCompress.LastErrorText & @CRLF) Exit EndIf Local $sOriginalText = $oBdDecompressed.GetString("utf-8") ConsoleWrite($sOriginalText & @CRLF) |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.