Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Compress String Feed to Base64This example receives incoming text data in chunks, compresses as a stream, and accumulates the compressed data in base64. The purpose is to demonstrate the BeginCompressStringENC, MoreCompressStringENC, and EndCompressStringENC methods.
integer li_rc integer li_Success oleobject loo_SbCompressedBase64 oleobject loo_Compress oleobject loo_SbIndex integer i string ls_OriginalText // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_SbCompressedBase64 = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbCompressedBase64.ConnectToNewObject("Chilkat.StringBuilder") if li_rc < 0 then destroy loo_SbCompressedBase64 MessageBox("Error","Connecting to COM object failed") return end if loo_Compress = create oleobject // Use "Chilkat_9_5_0.Compression" for versions of Chilkat < 10.0.0 li_rc = loo_Compress.ConnectToNewObject("Chilkat.Compression") loo_Compress.Algorithm = "deflate" loo_Compress.Charset = "utf-8" loo_Compress.EncodingMode = "base64" loo_SbIndex = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbIndex.ConnectToNewObject("Chilkat.StringBuilder") for i = 0 to 24 // Note: It is possible (and normal) for a BeginCompress* or MoreCompress* method to return // an empty string (or 0 bytes). When this happens, the input data is not lost. It will be flushed // in a subsequent call. loo_SbIndex.Clear() loo_SbIndex.AppendInt(i) if i = 0 then loo_SbCompressedBase64.Append(loo_Compress.BeginCompressStringENC(loo_SbIndex.GetAsString())) else loo_SbCompressedBase64.Append(loo_Compress.MoreCompressStringENC(loo_SbIndex.GetAsString())) end if loo_SbCompressedBase64.Append(loo_Compress.MoreCompressStringENC(": This is a line of data to be compressed...~r~n")) next // Flush any remaining output. loo_SbCompressedBase64.Append(loo_Compress.EndCompressStringENC()) Write-Debug "The base64 encoded compressed text:" Write-Debug loo_SbCompressedBase64.GetAsString() // Now decompress in one call: ls_OriginalText = loo_Compress.DecompressStringENC(loo_SbCompressedBase64.GetAsString()) Write-Debug ls_OriginalText destroy loo_SbCompressedBase64 destroy loo_Compress destroy loo_SbIndex |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.