C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C# Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

GZip Compress String

Download Chilkat .NET for 4.0 Framework

Download Chilkat .NET for 64-bit 4.0 Framework (x64)

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 64-bit 2.0 / 3.5 Framework (x64)

Download Chilkat .NET for 1.0 / 1.1 Framework

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.

Chilkat.Gzip gzip = new Chilkat.Gzip();

bool success;

//  Any string unlocks the component for the 1st 30-days.
success = gzip.UnlockComponent("Anything for 30-day trial");
if (success != true) {
    MessageBox.Show(gzip.LastErrorText);
    return;
}

//  Create a string that is somewhat large.
string s;
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.
string cs;
cs = gzip.DeflateStringENC(s,"windows-1252","base64");
textBox1.Text += cs + "\r\n";

//  Inflate to restore the string:
string s2;
s2 = gzip.InflateStringENC(cs,"windows-1252","base64");
textBox1.Text += s2 + "\r\n";
 

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

Email Component · XML Parser