![]() |
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
(Lianja) 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.
llSuccess = .F. // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loBdCompressed = createobject("CkBinData") loCompress = createobject("CkCompression") loCompress.Algorithm = "deflate" loCompress.Charset = "utf-8" loSbUncompressedChunk = createobject("CkStringBuilder") loCompress.FirstChunk = .T. loCompress.LastChunk = .F. for i = 0 to 24 if (i = 24) then loCompress.LastChunk = .T. endif loSbUncompressedChunk.Clear() loSbUncompressedChunk.AppendInt(i) loSbUncompressedChunk.Append(": This is a line of data to be compressed..." + Chr(13) + Chr(10)) loCompress.CompressSb(loSbUncompressedChunk,loBdCompressed) loCompress.FirstChunk = .F. next // Show the compressed data in hex format: ? "The hex encoded compressed text:" ? loBdCompressed.GetEncoded("hex") // Now decompress in one call. It is important to set both FirstChunk and LastChunk = .T. loBdDecompressed = createobject("CkBinData") loCompress.FirstChunk = .T. loCompress.LastChunk = .T. llSuccess = loCompress.DecompressBd2(loBdCompressed,loBdDecompressed) if (llSuccess = .F.) then ? loCompress.LastErrorText release loBdCompressed release loCompress release loSbUncompressedChunk release loBdDecompressed return endif lcOriginalText = loBdDecompressed.GetString("utf-8") ? lcOriginalText release loBdCompressed release loCompress release loSbUncompressedChunk release loBdDecompressed |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.