---
product: Chilkat
product_version: 11.7.0
language: asp
language_label: Classic ASP
class: Compression
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/asp_CompressionRef.html
---
# Chilkat Compression — Classic ASP — v11.7.0

> Chilkat 11.7.0 · language=asp · class=Compression
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/Compression.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/asp/guide.md`.

## Purpose

**Compress and decompress bytes, text, files, and streams with a flexible API.**

`Chilkat.Compression` provides a general-purpose API for compressing and decompressing data in memory, files, and streams. It supports multiple algorithms, text charset conversion, encoded output, chunked processing, and streaming operations for large data.

**Multiple algorithms**

Supports `deflate`, `zlib`, `bzip2`, and `lzw`.

**Flexible data types**

Work with byte arrays, strings, `BinData`, `StringBuilder`, files, and streams.

**Chunked processing**

Process data incrementally with `FirstChunk` and `LastChunk` for chunk-aware methods.

**Encoded output**

Return compressed bytes as text using encodings such as `base64`, `hex`, and others.

**Streaming support**

Compress or decompress large files and streams with stable memory usage.

**Compression + encryption**

Combine compression and encryption in file workflows with integrated methods.

**Tip:** For text compression, explicitly set `Charset = "utf-8"` unless another encoding is required. For encoded compressed data, set `EncodingMode` to the desired output format.

For an extended overview, see [Compression Class Overview](https://www.chilkatsoft.com/compression_class_overview.asp). See also [Binary Encodings](https://www.chilkatsoft.com/binary_encodings.asp) for supported encoded output formats.

## Object creation, unlocking and error handling

**Object Creation**

```visual-basic
set compression = Server.CreateObject("Chilkat.Compression")

' ... use compression ...

set compression = Nothing
```

Classic ASP creates Chilkat objects with `Server.CreateObject`. The registered Chilkat ActiveX must match the bitness of the IIS application pool: a pool with *Enable 32-Bit Applications* set to True needs the 32-bit ActiveX, otherwise the 64-bit ActiveX. To bind to a specific major version of Chilkat, append the major version number to the ProgID, such as `Server.CreateObject("Chilkat.Compression.11")` for Chilkat v11.\*.\*.

VBScript requires `set` when assigning an object, so the signatures on this page show `set x = obj.Method(...)` for methods that return a Chilkat object; test the result with `Is Nothing`, since a method that fails to return an object returns `Nothing`. A method with no return value is called as a statement without parentheses (`obj.Method arg1, arg2`). Boolean properties, arguments and return values are integers in the ActiveX: pass `1` or `0`, and test success with `= 1`. Byte arrays are Variant arrays and can be sent with `Response.BinaryWrite`. Asynchronous (*\*Async*) methods and event callbacks are not used from Classic ASP.

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in Classic ASP.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `compression.DebugLogFilePath ' String` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastBinaryResult` | `compression.LastBinaryResult ' Variant (read-only)` | read-only | This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. |
| `LastErrorHtml` | `compression.LastErrorHtml ' String (read-only)` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `compression.LastErrorText ' String (read-only)` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `compression.LastErrorXml ' String (read-only)` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `compression.LastMethodSuccess ' Long` | read/write | Indicates the success or failure of the most recent method call: `1` means success, `0` means failure. |
| `LastStringResult` | `compression.LastStringResult ' String (read-only)` | read-only | In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. |
| `LastStringResultLen` | `compression.LastStringResultLen ' Long (read-only)` | read-only | The length, in characters, of the string contained in the LastStringResult property. |
| `VerboseLogging` | `compression.VerboseLogging ' Long` | read/write | If set to `1`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `compression.Version ' String (read-only)` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `Algorithm` | property, read/write | `compression.Algorithm ' String` |
| `Charset` | property, read/write | `compression.Charset ' String` |
| `DeflateLevel` | property, read/write | `compression.DeflateLevel ' Long` |
| `EncodingMode` | property, read/write | `compression.EncodingMode ' String` |
| `FirstChunk` | property, read/write | `compression.FirstChunk ' Long` |
| `LastChunk` | property, read/write | `compression.LastChunk ' Long` |
| `UncommonOptions` | property, read/write | `compression.UncommonOptions ' String` |
| `CompressBd` | method | `success = compression.CompressBd(bd) ' Long (1/0)` |
| `CompressBd2` | method | `success = compression.CompressBd2(bdIn, bdOut) ' Long (1/0)` |
| `CompressBytes` | method | `bytes = compression.CompressBytes(data) ' Variant` |
| `CompressBytesENC` | method | `str = compression.CompressBytesENC(data) ' String` |
| `CompressEncryptFile` | method | `success = compression.CompressEncryptFile(cryptParams, srcPath, destPath) ' Long (1/0)` |
| `CompressFile` | method | `success = compression.CompressFile(srcPath, destPath) ' Long (1/0)` |
| `CompressSb` | method | `success = compression.CompressSb(sb, binData) ' Long (1/0)` |
| `CompressStr` | method | `success = compression.CompressStr(str, bd) ' Long (1/0)` |
| `CompressStream` | method | `success = compression.CompressStream(strm) ' Long (1/0)` |
| `CompressString` | method | `bytes = compression.CompressString(str) ' Variant` |
| `CompressStringENC` | method | `str = compression.CompressStringENC(str) ' String` |
| `DecompressBd` | method | `success = compression.DecompressBd(bd) ' Long (1/0)` |
| `DecompressBd2` | method | `success = compression.DecompressBd2(bdIn, bdOut) ' Long (1/0)` |
| `DecompressBytes` | method | `bytes = compression.DecompressBytes(data) ' Variant` |
| `DecompressBytesENC` | method | `bytes = compression.DecompressBytesENC(encodedCompressedData) ' Variant` |
| `DecompressFile` | method | `success = compression.DecompressFile(srcPath, destPath) ' Long (1/0)` |
| `DecompressSb` | method | `success = compression.DecompressSb(binData, sb) ' Long (1/0)` |
| `DecompressStream` | method | `success = compression.DecompressStream(strm) ' Long (1/0)` |
| `DecompressString` | method | `str = compression.DecompressString(data) ' String` |
| `DecompressStringENC` | method | `str = compression.DecompressStringENC(encodedCompressedData) ' String` |
| `DecryptDecompressFile` | method | `success = compression.DecryptDecompressFile(cryptParams, srcPath, destPath) ' Long (1/0)` |

Deprecated members are listed at the end of this file with their replacements; do not use them in new code.

## Properties

### Compression.Algorithm

`Chilkat 11.7.0 · asp · Compression · Algorithm · property · read/write`

```visual-basic
compression.Algorithm  ' String
```

Specifies the compression algorithm to use. Supported values are `deflate`, `zlib`, `gzip`, `bzip2`, and `lzw`.

The `zlib` option is the deflate algorithm with a zlib header.

The `gzip` option (starting in v11.7.0) is the deflate algorithm in the gzip format (RFC 1952): a gzip header, the deflate data, and a trailer with the CRC-32 and size of the uncompressed data. When decompressing in one call, the CRC-32 and size are checked. Before v11.7.0, `gzip` was not recognized and was treated as `deflate`.

**Note:** `ppmd` is deprecated and should not be used. It was only available on 32-bit systems and specifically used the J variant. New applications should use one of the supported algorithms listed above.

### Compression.Charset

`Chilkat 11.7.0 · asp · Compression · Charset · property · read/write`

```visual-basic
compression.Charset  ' String
```

**Full documentation for this property (same in every language):** [How Character Encoding (Charset) Affects Compression and Decompression](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/how_charset_affects_compression.md) · [Full List of Character Encodings Supported by Chilkat](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/charsets_supported_by_chilkat.md)

Specifies the character encoding used when converting text to bytes before compression, and bytes back to text after decompression.

The current default is the computer’s ANSI charset, such as Windows-1252 on many Western Windows systems. However, most modern applications should explicitly set this property to `utf-8`.

**Recommendation:** Set `Charset = "utf-8"` unless you specifically need compatibility with another encoding.

### Compression.DeflateLevel

`Chilkat 11.7.0 · asp · Compression · DeflateLevel · property · read/write · since 9.5.0.73`

```visual-basic
compression.DeflateLevel  ' Long
```

Sets the compression level used by the `deflate` and `zlib` algorithms.

- `0` means no compression.
- `9` means maximum compression.
- The default value is `6`.

Higher values may produce smaller output but can require more processing time.

### Compression.EncodingMode

`Chilkat 11.7.0 · asp · Compression · EncodingMode · property · read/write`

```visual-basic
compression.EncodingMode  ' String
```

**Full documentation for this property (same in every language):** [Binary Encodings Supported by Chilkat](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/binary_encodings.md)

Specifies the text encoding used by methods whose names end in `ENC`, such as `CompressBytesENC` and `DecompressStringENC`.

Compression methods ending in `ENC` return compressed binary data as an encoded string. Decompression methods ending in `ENC` expect the input string to use this same encoding.

Valid values include:

- `base64`
- `hex`
- `url`
- `quoted-printable`

### Compression.FirstChunk

`Chilkat 11.7.0 · asp · Compression · FirstChunk · property · read/write · since 11.0.0`

```visual-basic
compression.FirstChunk  ' Long
```

Indicates that the next chunk-aware compression or decompression call is the first chunk in a sequence.

The default value is `1`.

When both `FirstChunk` and `LastChunk` are `1`, the method call is treated as a complete, single-call compression or decompression operation.

### Compression.LastChunk

`Chilkat 11.7.0 · asp · Compression · LastChunk · property · read/write · since 11.0.0`

```visual-basic
compression.LastChunk  ' Long
```

Indicates that the next chunk-aware compression or decompression call is the final chunk in a sequence.

The default value is `1`.

When both `FirstChunk` and `LastChunk` are `1`, the input is treated as the complete data set and processed in a single call.

### Compression.UncommonOptions

`Chilkat 11.7.0 · asp · Compression · UncommonOptions · property · read/write · since 11.0.0`

```visual-basic
compression.UncommonOptions  ' String
```

Provides a way to enable specialized or uncommon behavior. This property normally remains empty.

It may be set to a comma-separated list of keywords.

Supported option:

- `Crypt2CompressHdr` — Duplicates the compression/decompression header behavior used by the deprecated and removed Crypt2 compression functions.

## Methods

### Compression.CompressBd

`Chilkat 11.7.0 · asp · Compression · CompressBd · method · since 9.5.0.66`

```visual-basic
success = compression.CompressBd(bd)  ' Long (1/0)
```

Compresses the data contained in a `BinData` object.

The `BinData` object is modified to contain the compressed result.

This method is not `FirstChunk` / `LastChunk` aware.

Returns 1 for success, 0 for failure.

### Compression.CompressBd2

`Chilkat 11.7.0 · asp · Compression · CompressBd2 · method · since 11.0.0`

```visual-basic
success = compression.CompressBd2(bdIn, bdOut)  ' Long (1/0)
```

Compresses the data in one `BinData` object and appends the compressed output to another `BinData` object.

The input `BinData` is not modified.

This method is `FirstChunk` / `LastChunk` aware.

Returns 1 for success, 0 for failure.

### Compression.CompressBytes

`Chilkat 11.7.0 · asp · Compression · CompressBytes · method`

```visual-basic
bytes = compression.CompressBytes(data)  ' Variant
```

Compresses a byte array and returns the compressed bytes.

This method is `FirstChunk` / `LastChunk` aware.

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

### Compression.CompressBytesENC

`Chilkat 11.7.0 · asp · Compression · CompressBytesENC · method`

```visual-basic
str = compression.CompressBytesENC(data)  ' String
```

Compresses a byte array and returns the compressed result as an encoded string.

The output encoding is controlled by `EncodingMode`.

This method is not `FirstChunk` / `LastChunk` aware.

Returns `Nothing` on failure

### Compression.CompressEncryptFile

`Chilkat 11.7.0 · asp · Compression · CompressEncryptFile · method · since 9.5.0.99`

```visual-basic
success = compression.CompressEncryptFile(cryptParams, srcPath, destPath)  ' Long (1/0)
```

Compresses and encrypts a file, writing the result to a destination file.

The compression and encryption are performed internally in streaming mode, so files of any size can be processed without loading the entire file into memory.

Returns 1 for success, 0 for failure.

### Compression.CompressFile

`Chilkat 11.7.0 · asp · Compression · CompressFile · method`

```visual-basic
success = compression.CompressFile(srcPath, destPath)  ' Long (1/0)
```

Compresses a source file and writes the compressed data to a destination file.

The file is processed internally in streaming mode, allowing files of any size to be compressed with stable memory usage.

Returns 1 for success, 0 for failure.

### Compression.CompressSb

`Chilkat 11.7.0 · asp · Compression · CompressSb · method · since 9.5.0.73`

```visual-basic
success = compression.CompressSb(sb, binData)  ' Long (1/0)
```

Compresses the text contained in a `StringBuilder` and appends the compressed bytes to a `BinData` object.

Text is converted to bytes according to the `Charset` property.

This method is `FirstChunk` / `LastChunk` aware.

Returns 1 for success, 0 for failure.

### Compression.CompressStr

`Chilkat 11.7.0 · asp · Compression · CompressStr · method · since 11.0.0`

```visual-basic
success = compression.CompressStr(str, bd)  ' Long (1/0)
```

Compresses a string and appends the compressed bytes to a `BinData` object.

The string is converted to bytes using the charset specified by the `Charset` property.

This method is `FirstChunk` / `LastChunk` aware.

Returns 1 for success, 0 for failure.

### Compression.CompressStream

`Chilkat 11.7.0 · asp · Compression · CompressStream · method · since 9.5.0.56`

```visual-basic
success = compression.CompressStream(strm)  ' Long (1/0)
```

Compresses data from a stream source and writes the compressed data to the stream sink.

The operation is performed in streaming mode, making it suitable for very large or even continuous streams while maintaining stable memory usage.

Returns 1 for success, 0 for failure.

### Compression.CompressString

`Chilkat 11.7.0 · asp · Compression · CompressString · method`

```visual-basic
bytes = compression.CompressString(str)  ' Variant
```

Compresses a string and returns the compressed bytes.

The string is converted to bytes using the `Charset` property.

This method is `FirstChunk` / `LastChunk` aware.

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

### Compression.CompressStringENC

`Chilkat 11.7.0 · asp · Compression · CompressStringENC · method`

```visual-basic
str = compression.CompressStringENC(str)  ' String
```

Compresses a string and returns the compressed result as an encoded string.

The string is first converted to bytes using `Charset`, then compressed, and finally encoded according to `EncodingMode`.

This method is not `FirstChunk` / `LastChunk` aware.

Returns `Nothing` on failure

### Compression.DecompressBd

`Chilkat 11.7.0 · asp · Compression · DecompressBd · method · since 9.5.0.66`

```visual-basic
success = compression.DecompressBd(bd)  ' Long (1/0)
```

Decompresses the compressed data contained in a `BinData` object.

The `BinData` object is modified to contain the decompressed result.

This method is not `FirstChunk` / `LastChunk` aware.

Returns 1 for success, 0 for failure.

### Compression.DecompressBd2

`Chilkat 11.7.0 · asp · Compression · DecompressBd2 · method · since 11.0.0`

```visual-basic
success = compression.DecompressBd2(bdIn, bdOut)  ' Long (1/0)
```

Decompresses the data in one `BinData` object and appends the decompressed output to another `BinData` object.

The input `BinData` is not modified.

This method is `FirstChunk` / `LastChunk` aware.

Returns 1 for success, 0 for failure.

### Compression.DecompressBytes

`Chilkat 11.7.0 · asp · Compression · DecompressBytes · method`

```visual-basic
bytes = compression.DecompressBytes(data)  ' Variant
```

Decompresses compressed byte data and returns the decompressed bytes.

This method is `FirstChunk` / `LastChunk` aware.

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

### Compression.DecompressBytesENC

`Chilkat 11.7.0 · asp · Compression · DecompressBytesENC · method`

```visual-basic
bytes = compression.DecompressBytesENC(encodedCompressedData)  ' Variant
```

Decompresses compressed data supplied as an encoded string and returns the decompressed bytes.

The input string is decoded according to `EncodingMode` before being decompressed.

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

### Compression.DecompressFile

`Chilkat 11.7.0 · asp · Compression · DecompressFile · method`

```visual-basic
success = compression.DecompressFile(srcPath, destPath)  ' Long (1/0)
```

Decompresses a source file and writes the decompressed data to a destination file.

The file is processed internally in streaming mode, allowing files of any size to be decompressed without loading the entire file into memory.

Returns 1 for success, 0 for failure.

### Compression.DecompressSb

`Chilkat 11.7.0 · asp · Compression · DecompressSb · method · since 9.5.0.73`

```visual-basic
success = compression.DecompressSb(binData, sb)  ' Long (1/0)
```

Decompresses compressed data from a `BinData` object and appends the resulting text to a `StringBuilder`.

The decompressed bytes are converted to text using the `Charset` property.

This method is `FirstChunk` / `LastChunk` aware.

Returns 1 for success, 0 for failure.

### Compression.DecompressStream

`Chilkat 11.7.0 · asp · Compression · DecompressStream · method · since 9.5.0.56`

```visual-basic
success = compression.DecompressStream(strm)  ' Long (1/0)
```

Decompresses data from a stream source and writes the decompressed data to the stream sink.

The operation is performed in streaming mode, making it suitable for very large or continuous streams while maintaining stable memory usage.

Returns 1 for success, 0 for failure.

### Compression.DecompressString

`Chilkat 11.7.0 · asp · Compression · DecompressString · method`

```visual-basic
str = compression.DecompressString(data)  ' String
```

Decompresses compressed byte data and returns the resulting string.

The decompressed bytes are converted to text using the `Charset` property.

This method is `FirstChunk` / `LastChunk` aware.

Returns `Nothing` on failure

### Compression.DecompressStringENC

`Chilkat 11.7.0 · asp · Compression · DecompressStringENC · method`

```visual-basic
str = compression.DecompressStringENC(encodedCompressedData)  ' String
```

Decompresses compressed data supplied as an encoded string and returns the resulting text.

The input string is decoded according to `EncodingMode`, then decompressed. The resulting bytes are converted to text using `Charset`.

This method is not `FirstChunk` / `LastChunk` aware.

Returns `Nothing` on failure

### Compression.DecryptDecompressFile

`Chilkat 11.7.0 · asp · Compression · DecryptDecompressFile · method · since 9.5.0.99`

```visual-basic
success = compression.DecryptDecompressFile(cryptParams, srcPath, destPath)  ' Long (1/0)
```

Decrypts and decompresses a file, writing the restored data to a destination file.

This is the reverse operation of `CompressEncryptFile`.

Returns 1 for success, 0 for failure.

## Events and callbacks

This binding has no event callbacks.

## Deprecated members — do not use in new code

| Member | Kind | Deprecated in | Use instead |
|---|---|---|---|
| `BeginCompressBytes` | method | before 11.6.1 | `FirstChunk` |
| `BeginCompressBytesENC` | method | before 11.6.1 | — |
| `BeginCompressString` | method | before 11.6.1 | `FirstChunk` |
| `BeginCompressStringENC` | method | before 11.6.1 | `FirstChunk` |
| `BeginDecompressBytes` | method | before 11.6.1 | `FirstChunk` |
| `BeginDecompressBytesENC` | method | before 11.6.1 | `FirstChunk` |
| `BeginDecompressString` | method | before 11.6.1 | `FirstChunk` |
| `BeginDecompressStringENC` | method | before 11.6.1 | `FirstChunk` |
| `EndCompressBytes` | method | before 11.6.1 | — |
| `EndCompressBytesENC` | method | before 11.6.1 | — |
| `EndCompressString` | method | before 11.6.1 | — |
| `EndCompressStringENC` | method | before 11.6.1 | — |
| `EndDecompressBytes` | method | before 11.6.1 | — |
| `EndDecompressBytesENC` | method | before 11.6.1 | — |
| `EndDecompressString` | method | before 11.6.1 | — |
| `EndDecompressStringENC` | method | before 11.6.1 | — |
| `MoreCompressBytes` | method | before 11.6.1 | — |
| `MoreCompressBytesENC` | method | before 11.6.1 | — |
| `MoreCompressString` | method | before 11.6.1 | — |
| `MoreCompressStringENC` | method | before 11.6.1 | — |
| `MoreDecompressBytes` | method | before 11.6.1 | — |
| `MoreDecompressBytesENC` | method | before 11.6.1 | — |
| `MoreDecompressString` | method | before 11.6.1 | — |
| `MoreDecompressStringENC` | method | before 11.6.1 | — |

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/asp/classes/BinData.md), [`JsonObject`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/asp/classes/JsonObject.md), [`Stream`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/asp/classes/Stream.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/asp/classes/StringBuilder.md)

