![]() |
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 and Decompress a StringDemonstrates how to compress and decompress a string.
; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. Local $bSuccess $oSb = ObjCreate("Chilkat_9_5_0.StringBuilder") Local $i For $i = 1 To 20 $oSb.Append("This is the original uncompressed string." & @CRLF) Next $oCompress = ObjCreate("Chilkat_9_5_0.Compression") $oCompress.Algorithm = "deflate" ; Indicate that the utf-8 byte representation of the string should be compressed. $oCompress.Charset = "utf-8" Local $oCompressedBytes $oCompressedBytes = $oCompress.CompressString($oSb.GetAsString()) ; If the compressed data is desired in string format, then get the base64 representation of the bytes. $oCompress.EncodingMode = "base64" Local $sCompressedBase64 = $oCompress.CompressStringENC($oSb.GetAsString()) ConsoleWrite("Compressed Bytes as Base64: " & $sCompressedBase64 & @CRLF) ; Now decompress... Local $sDecompressedString = $oCompress.DecompressString($oCompressedBytes) ConsoleWrite("The original string after decompressing from binary compressed data:" & @CRLF) ConsoleWrite($sDecompressedString & @CRLF) ; To decompress from Base64... $oCompress.EncodingMode = "base64" $sDecompressedString = $oCompress.DecompressStringENC($sCompressedBase64) ConsoleWrite("The original string after decompressing from Base64:" & @CRLF) ConsoleWrite($sDecompressedString & @CRLF) |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.