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 Bytes to Base64 (or any other encoding)Compresses bytes to base64 or any other encoding. Also decompress to return the original.
integer li_rc integer li_Success oleobject loo_BinData integer i oleobject loo_Compress string ls_CompressedBase64 string ls_CompressedHex oleobject loo_BinData2 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // First create some binary data to compress. loo_BinData = create oleobject // Use "Chilkat_9_5_0.BinData" for versions of Chilkat < 10.0.0 li_rc = loo_BinData.ConnectToNewObject("Chilkat.BinData") if li_rc < 0 then destroy loo_BinData MessageBox("Error","Connecting to COM object failed") return end if for i = 1 to 16 loo_BinData.AppendEncoded("000102030405060708090A0B0C0D0E0F","hex") next 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.EncodingMode = "base64" loo_UncompressedBytes = loo_BinData.GetBinary() // Compress and return the compressed bytes in base64 format. ls_CompressedBase64 = loo_Compress.CompressBytesENC(loo_UncompressedBytes) Write-Debug "compressed and base64 encoded: " + ls_CompressedBase64 // Compress and return in hex format: loo_Compress.EncodingMode = "hex" ls_CompressedHex = loo_Compress.CompressBytesENC(loo_UncompressedBytes) Write-Debug "compressed and hex encoded: " + ls_CompressedHex // Now decompress.. loo_BinData2 = create oleobject // Use "Chilkat_9_5_0.BinData" for versions of Chilkat < 10.0.0 li_rc = loo_BinData2.ConnectToNewObject("Chilkat.BinData") // Decompress the base64.. loo_Compress.EncodingMode = "base64" loo_UncompressedBytes = loo_Compress.DecompressBytesENC(ls_CompressedBase64) loo_BinData2.AppendBinary(loo_UncompressedBytes) // Show the uncompressed bytes in hex format: Write-Debug loo_BinData2.GetEncoded("hex") Write-Debug "--" // Decompress the hex.. loo_Compress.EncodingMode = "hex" loo_UncompressedBytes = loo_Compress.DecompressBytesENC(ls_CompressedHex) loo_BinData2.Clear() loo_BinData2.AppendBinary(loo_UncompressedBytes) // Show the uncompressed bytes in hex format: Write-Debug loo_BinData2.GetEncoded("hex") Write-Debug "--" destroy loo_BinData destroy loo_Compress destroy loo_BinData2 |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.