Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode 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
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
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
MS Storage Providers
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
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

 

 

 

GZip Compress String

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Compress and uncompress strings using the deflate algorithm. The underlying compression algorithm used by GZip is the deflate compression algorithm, which is also the most common algorithm used in the Zip file format (.zip). This method compresses a string by first converting it to the specified charset. This is necessary for programming languages where strings are represented as 2-byte/char Unicode. By indicating a charset, the size is already "comrpessed" by 50% (if the characters are an iso-8859 or windows-125* charset).

After charset conversion, the bytes are deflated. Finally, the resultant binary data is encoded according to the specified encoding ("base64", "hex", "url", "quoted-printable", etc.) and returned as a printable string. The most efficient encoding is Base64, which encodes 3 binary bytes in 4 printable characters.

Note: it only makes sense to compress strings that are long enough such that the expansion caused by (base64) encoding is relatively small.

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

'  Any string unlocks the component for the 1st 30-days.
success = gzip.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    Response.Write gzip.LastErrorText & "<br>"

End If

'  Create a string that is somewhat large.

s = "A friend called me up the other day and talked about investing in a dot-com"
s = s & " that sells lobsters. Internet lobsters. Where will this end? --Donald Trump"
s = s + s
s = s + s

'  Deflate and print the compressed string.

cs = gzip.DeflateStringENC(s,"windows-1252","base64")
Response.Write Server.HTMLEncode( cs) & "<br>"

'  Inflate to restore the string:

s2 = gzip.InflateStringENC(cs,"windows-1252","base64")
Response.Write Server.HTMLEncode( s2) & "<br>"
%>
</body>
</html>

 

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