Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Classic ASP Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

PPMD Streaming String Compression

Demonstrates streaming string compression using PPMD. Data may be compressed in chunks by initially calling one of the BeginCompress* methods, followed by 0 or more calls to a MoreCompress* method, and terminating with a call to an EndCompress* method.

Likewise, data may be decompressed by calling a BeginDecompress* method, followed by 0 or more MoreDecompress* calls, and ending with an EndDecompress* method call.

This example demonstrates string-to-string compression and decompression in chunks.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set compress = Server.CreateObject("Chilkat_9_5_0.Compression")

'  Any string argument automatically begins a 30-day trial.
success = compress.UnlockComponent("30-day trial")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode("Compression component unlock failed") & "</pre>"

End If

compress.Algorithm = "ppmd"
compress.Charset = "ansi"
compress.EncodingMode = "base64"

'  Create a long string to compress.
strData = "abcdefg1122334455667788"
strData = strData & vbCrLf

'  Note: BeginCompressStringENC may return a zero-length
'  string.  This is normal if the input is buffered and no
'  compressed data is yet available.
'  However, a null reference indicates an error -- which is
'  generally only possible if the component was never unlocked.
strCompressed = compress.BeginCompressStringENC(strData)

'  Compress 100 more chunks of data.  Each call to
'  MoreCompressStringENC may or may not produce additional
'  compressed output.
For i = 0 To 99
    strData = "abcdefg1122334455667788"
    strData = strData & vbCrLf

    strCompressed = strCompressed & compress.MoreCompressStringENC(strData)
Next

'  Finalize the compression with a single call to EndCompressStringENC:
strCompressed = strCompressed & compress.EndCompressStringENC()

'  Display the compressed string.
'  The result will be:
'  ec8YZ5vk9za18d0plwuV7R65em9OZge9gJXht/QAAAAAAAAAABNOZQAAKw==

Response.Write "<pre>" & Server.HTMLEncode( strCompressed) & "</pre>"

'  Decompress back to the original in a single call.

strOriginal = compress.DecompressStringENC(strCompressed)

'  Display the uncompressed original:
Response.Write "<pre>" & Server.HTMLEncode( "--- Original ---") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( strOriginal) & "</pre>"

'  Decompress in multiple calls.  It doesn't matter how the
'  compressed data is split -- it could be fed to the decompressor
'  one char at a time if desired.
chunk1 = "ec8YZ5vk9za1"
chunk2 = "8d0p"
chunk3 = "lwuV7R65em9OZge9gJXht/QAAAA"
chunk4 = "AAAAAABNOZQAAKw=="

strOriginal = ""
strOriginal = compress.BeginDecompressStringENC(chunk1)
strOriginal = strOriginal & compress.MoreDecompressStringENC(chunk2)
strOriginal = strOriginal & compress.MoreDecompressStringENC(chunk3)
strOriginal = strOriginal & compress.MoreDecompressStringENC(chunk4)
strOriginal = strOriginal & compress.EndDecompressStringENC()

'  Display the uncompressed original after decompressing in chunks:
Response.Write "<pre>" & Server.HTMLEncode( "--- Original after Decompressing from Chunks ---") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( strOriginal) & "</pre>"
%>
</body>
</html>

 

© 2000-2026 Chilkat Software, Inc. All Rights Reserved.