CkCompression Ruby Programming
Reference Documentation

CkCompression

Data compression component implementing the PPMD, Bzip2, Deflate, and LZW compression algorithms. .NET, ActiveX, and C++ implementations provide progress monitoring and abort capabilities. Provides a unified API for all supported compression algorithms.

Object Creation

obj = Chilkat::CkCompression.new()

Properties

# str is a CkString object (output)
get_Algorithm( str )

# newVal is a string (input)
put_Algorithm( newVal )

The compression algorithm to be used. Should be set to either "ppmd", "deflate", "bzip2", or "lzw".

Note: The PPMD compression algorithm is only available for Windows OS builds. It is not yet available on non-Windows platforms.

# str is a CkString object (output)
get_Charset( str )

# newVal is a string (input)
put_Charset( newVal )

Only applies to methods that compress or decompress strings. This specifies the character encoding that the string should be converted to before compression. Many programming languages use Unicode (2 bytes per char) for representing characters. This property allows for the string to be converted to a 1-byte per char encoding prior to compression.

# str is a CkString object (output)
get_EncodingMode( str )

# newVal is a string (input)
put_EncodingMode( newVal )

Controls the encoding expected by methods ending in "ENC", such as CompressBytesENC. Valid values are "base64", "hex", "url", and "quoted-printable". Compression methods ending in ENC return the binary compressed data as an encoded string using this encoding. Decompress methods expect the input string to be this encoding.

# str is a CkString object (output)
LastErrorHtml( str )

Error information in HTML format for the last method called.

# str is a CkString object (output)
LastErrorText( str )

Error information in plain-text format for the last method called.

# str is a CkString object (output)
LastErrorXml( str )

Error information in XML format for the last method called.

# Returns a boolean value
get_Utf8( )

# b is a boolean (input)
put_Utf8( b )

When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.

# str is a CkString object (output)
get_Version( str )

A version string, such as "1.2.0"

Methods

# data is a CkByteData object (output)
# outBytes is a CkByteData object (output)
# Returns a boolean value
BeginCompressBytes( data, outBytes )

Large amounts of binary byte data may be compressed in chunks by first calling BeginCompressBytes, followed by 0 or more calls to MoreCompressedBytes, and ending with a final call to EndCompressBytes. Each call returns 0 or more bytes of compressed data which may be output to a compressed data stream (such as a file, socket, etc.).

# data is a CkByteData object (output)
# outStr is a CkString object (output)
# Returns a boolean value
BeginCompressBytesENC( data, outStr )

Large amounts of binary byte data may be compressed in chunks by first calling BeginCompressBytesENC, followed by 0 or more calls to MoreCompressedBytesENC, and ending with a final call to EndCompressBytesENC. Each call returns 0 or more characters of compressed data (encoded as a string according to the EncodingMode property setting) which may be output to a compressed data stream (such as a file, socket, etc.).

Returns true for success, false for failure.

# str is a string (input)
# outBytes is a CkByteData object (output)
# Returns a boolean value
BeginCompressString( str, outBytes )

Large amounts of string data may be compressed in chunks by first calling BeginCompressString, followed by 0 or more calls to MoreCompressedString, and ending with a final call to EndCompressString. Each call returns 0 or more bytes of compressed data which may be output to a compressed data stream (such as a file, socket, etc.).

# str is a string (input)
# outStr is a CkString object (output)
# Returns a boolean value
BeginCompressStringENC( str, outStr )

Large amounts of string data may be compressed in chunks by first calling BeginCompressStringENC, followed by 0 or more calls to MoreCompressedStringENC, and ending with a final call to EndCompressStringENC. Each call returns 0 or more characters of compressed data (encoded as a string according to the EncodingMode property setting) which may be output to a compressed data stream (such as a file, socket, etc.).

Returns true for success, false for failure.

# data is a CkByteData object (output)
# outBytes is a CkByteData object (output)
# Returns a boolean value
BeginDecompressBytes( data, outBytes )

A compressed data stream may be decompressed in chunks by first calling BeginDecompressBytes, followed by 0 or more calls to MoreDecompressedBytes, and ending with a final call to EndDecompressBytes. Each call returns 0 or more bytes of decompressed data.

# str is a string (input)
# outBytes is a CkByteData object (output)
# Returns a boolean value
BeginDecompressBytesENC( str, outBytes )

The input to this method is an encoded string containing compressed data. The EncodingMode property should be set prior to calling this method. The input string is decoded according to the EncodingMode (hex, base64, etc.) and then decompressed.

A compressed data stream may be decompressed in chunks by first calling BeginDecompressBytesENC, followed by 0 or more calls to MoreDecompressedBytesENC, and ending with a final call to EndDecompressBytesENC. Each call returns 0 or more bytes of decompressed data.

# data is a CkByteData object (output)
# outStr is a CkString object (output)
# Returns a boolean value
BeginDecompressString( data, outStr )

A compressed data stream may be decompressed in chunks by first calling BeginDecompressString, followed by 0 or more calls to MoreDecompressedString, and ending with a final call to EndDecompressString. Each call returns 0 or more characters of decompressed text.

Returns true for success, false for failure.

# str is a string (input)
# outStr is a CkString object (output)
# Returns a boolean value
BeginDecompressStringENC( str, outStr )

The input to this method is an encoded string containing compressed data. The EncodingMode property should be set prior to calling this method. The input string is decoded according to the EncodingMode (hex, base64, etc.) and then decompressed.

A compressed data stream may be decompressed in chunks by first calling BeginDecompressStringENC, followed by 0 or more calls to MoreDecompressedStringENC, and ending with a final call to EndDecompressStringENC. Each call returns 0 or more characters of decompressed text.

Returns true for success, false for failure.

# data is a CkByteData object (output)
# outBytes is a CkByteData object (output)
# Returns a boolean value
CompressBytes( data, outBytes )

Compresses byte data.

# data is a CkByteData object (output)
# outStr is a CkString object (output)
# Returns a boolean value
CompressBytesENC( data, outStr )

Compresses bytes and returns the compressed data encoded to a string. The encoding (hex, base64, etc.) is determined by the EncodingMode property setting.

Returns true for success, false for failure.

# inFile is a string (input)
# outFile is a string (input)
# Returns a boolean value
CompressFile( inFile, outFile )

Performs file-to-file compression. Files of any size may be compressed because the file is compressed internally in streaming mode.

# str is a string (input)
# outBytes is a CkByteData object (output)
# Returns a boolean value
CompressString( str, outBytes )

Compresses a string.

# str is a string (input)
# outStr is a CkString object (output)
# Returns a boolean value
CompressStringENC( str, outStr )

Compresses a string and returns the compressed data encoded to a string. The output encoding (hex, base64, etc.) is determined by the EncodingMode property setting.

Returns true for success, false for failure.

# data is a CkByteData object (output)
# outBytes is a CkByteData object (output)
# Returns a boolean value
DecompressBytes( data, outBytes )

The opposite of CompressBytes.

# encodedCompressedData is a string (input)
# outBytes is a CkByteData object (output)
# Returns a boolean value
DecompressBytesENC( encodedCompressedData, outBytes )

The opposite of CompressBytesENC. encodedCompressedData contains the compressed data as an encoded string (hex, base64, etc) as specified by the EncodingMode property setting.

# inFile is a string (input)
# outFile is a string (input)
# Returns a boolean value
DecompressFile( inFile, outFile )

Performs file-to-file decompression (the opposite of CompressFile). Internally the file is decompressed in streaming mode which allows files of any size to be decompressed.

# data is a CkByteData object (output)
# outStr is a CkString object (output)
# Returns a boolean value
DecompressString( data, outStr )

Takes compressed bytes, decompresses, and returns the resulting string.

Returns true for success, false for failure.

# encodedCompressedData is a string (input)
# outStr is a CkString object (output)
# Returns a boolean value
DecompressStringENC( encodedCompressedData, outStr )

The opposite of CompressStringENC. encodedCompressedData contains the compressed data as an encoded string (hex, base64, etc) as specified by the EncodingMode property setting.

Returns true for success, false for failure.

# outBytes is a CkByteData object (output)
# Returns a boolean value
EndCompressBytes( outBytes )

Must be callled to finalize a compression stream. Returns any remaining (buffered) compressed data.

(See BeginCompressBytes)

# outStr is a CkString object (output)
# Returns a boolean value
EndCompressBytesENC( outStr )

Must be callled to finalize a compression stream. Returns any remaining (buffered) compressed data.

(See BeginCompressBytesENC)

Returns true for success, false for failure.

# outBytes is a CkByteData object (output)
# Returns a boolean value
EndCompressString( outBytes )

Must be callled to finalize a compression stream. Returns any remaining (buffered) compressed data.

(See BeginCompressString)

# outStr is a CkString object (output)
# Returns a boolean value
EndCompressStringENC( outStr )

Must be callled to finalize a compression stream. Returns any remaining (buffered) compressed data.

(See BeginCompressStringENC)

Returns true for success, false for failure.

# outBytes is a CkByteData object (output)
# Returns a boolean value
EndDecompressBytes( outBytes )

Called to finalize the decompression stream and return any remaining (buffered) decompressed data.

(See BeginDecompressBytes)

# outBytes is a CkByteData object (output)
# Returns a boolean value
EndDecompressBytesENC( outBytes )

Called to finalize the decompression stream and return any remaining (buffered) decompressed data.

The input to this method is an encoded string containing compressed data. The EncodingMode property should be set prior to calling this method. The input string is decoded according to the EncodingMode (hex, base64, etc.) and then decompressed.

(See BeginDecompressBytesENC)

# outStr is a CkString object (output)
# Returns a boolean value
EndDecompressString( outStr )

Called to finalize the decompression stream and return any remaining (buffered) decompressed data.

(See BeginDecompressString)

Returns true for success, false for failure.

# outStr is a CkString object (output)
# Returns a boolean value
EndDecompressStringENC( outStr )

Called to finalize the decompression stream and return any remaining (buffered) decompressed data.

The input to this method is an encoded string containing compressed data. The EncodingMode property should be set prior to calling this method. The input string is decoded according to the EncodingMode (hex, base64, etc.) and then decompressed.

(See BeginDecompressStringENC)

Returns true for success, false for failure.

# data is a CkByteData object (output)
# outBytes is a CkByteData object (output)
# Returns a boolean value
MoreCompressBytes( data, outBytes )

(See BeginCompressBytes)

# data is a CkByteData object (output)
# outStr is a CkString object (output)
# Returns a boolean value
MoreCompressBytesENC( data, outStr )

(See BeginCompressBytesENC)

Returns true for success, false for failure.

# str is a string (input)
# outBytes is a CkByteData object (output)
# Returns a boolean value
MoreCompressString( str, outBytes )

(See BeginCompressString)

# str is a string (input)
# outStr is a CkString object (output)
# Returns a boolean value
MoreCompressStringENC( str, outStr )

(See BeginCompressStringENC)

Returns true for success, false for failure.

# data is a CkByteData object (output)
# outBytes is a CkByteData object (output)
# Returns a boolean value
MoreDecompressBytes( data, outBytes )

(See BeginDecompressBytes)

# str is a string (input)
# outBytes is a CkByteData object (output)
# Returns a boolean value
MoreDecompressBytesENC( str, outBytes )

The input to this method is an encoded string containing compressed data. The EncodingMode property should be set prior to calling this method. The input string is decoded according to the EncodingMode (hex, base64, etc.) and then decompressed.

(See BeginDecompressBytesENC)

# data is a CkByteData object (output)
# outStr is a CkString object (output)
# Returns a boolean value
MoreDecompressString( data, outStr )

(See BeginDecompressString)

Returns true for success, false for failure.

# str is a string (input)
# outStr is a CkString object (output)
# Returns a boolean value
MoreDecompressStringENC( str, outStr )

The input to this method is an encoded string containing compressed data. The EncodingMode property should be set prior to calling this method. The input string is decoded according to the EncodingMode (hex, base64, etc.) and then decompressed.

(See BeginDecompressStringENC)

Returns true for success, false for failure.

# filename is a string (input)
# Returns a boolean value
SaveLastError( filename )

Saves the last error information to an XML formatted file.

# unlockCode is a string (input)
# Returns a boolean value
UnlockComponent( unlockCode )

Unlocks the component allowing for the full functionality to be used. The component may be used fully-functional for the 1st 30-days after download by passing an arbitrary string to this method. If for some reason you do not receive the full 30-day trial, send email to support@chilkatsoft.com for a temporary unlock code w/ an explicit expiration date. Upon purchase, a permanent unlock code is provided which should replace the temporary/arbitrary string passed to this method.

# Returns a string
algorithm( )

The compression algorithm to be used. Should be set to either "ppmd", "deflate", "bzip2", or "lzw".

Note: The PPMD compression algorithm is only available for Windows OS builds. It is not yet available on non-Windows platforms.

Returns a null on failure

# data is a CkByteData object (output)
# Returns a string
beginCompressBytesENC( data )

Large amounts of binary byte data may be compressed in chunks by first calling BeginCompressBytesENC, followed by 0 or more calls to MoreCompressedBytesENC, and ending with a final call to EndCompressBytesENC. Each call returns 0 or more characters of compressed data (encoded as a string according to the EncodingMode property setting) which may be output to a compressed data stream (such as a file, socket, etc.).

Returns a null on failure

# str is a string (input)
# Returns a string
beginCompressStringENC( str )

Large amounts of string data may be compressed in chunks by first calling BeginCompressStringENC, followed by 0 or more calls to MoreCompressedStringENC, and ending with a final call to EndCompressStringENC. Each call returns 0 or more characters of compressed data (encoded as a string according to the EncodingMode property setting) which may be output to a compressed data stream (such as a file, socket, etc.).

Returns a null on failure

# data is a CkByteData object (output)
# Returns a string
beginDecompressString( data )

A compressed data stream may be decompressed in chunks by first calling BeginDecompressString, followed by 0 or more calls to MoreDecompressedString, and ending with a final call to EndDecompressString. Each call returns 0 or more characters of decompressed text.

Returns a null on failure

# str is a string (input)
# Returns a string
beginDecompressStringENC( str )

The input to this method is an encoded string containing compressed data. The EncodingMode property should be set prior to calling this method. The input string is decoded according to the EncodingMode (hex, base64, etc.) and then decompressed.

A compressed data stream may be decompressed in chunks by first calling BeginDecompressStringENC, followed by 0 or more calls to MoreDecompressedStringENC, and ending with a final call to EndDecompressStringENC. Each call returns 0 or more characters of decompressed text.

Returns a null on failure

# Returns a string
charset( )

Only applies to methods that compress or decompress strings. This specifies the character encoding that the string should be converted to before compression. Many programming languages use Unicode (2 bytes per char) for representing characters. This property allows for the string to be converted to a 1-byte per char encoding prior to compression.

Returns a null on failure

# data is a CkByteData object (output)
# Returns a string
compressBytesENC( data )

Compresses bytes and returns the compressed data encoded to a string. The encoding (hex, base64, etc.) is determined by the EncodingMode property setting.

Returns a null on failure

# str is a string (input)
# Returns a string
compressStringENC( str )

Compresses a string and returns the compressed data encoded to a string. The output encoding (hex, base64, etc.) is determined by the EncodingMode property setting.

Returns a null on failure

# data is a CkByteData object (output)
# Returns a string
decompressString( data )

Takes compressed bytes, decompresses, and returns the resulting string.

Returns a null on failure

# encodedCompressedData is a string (input)
# Returns a string
decompressStringENC( encodedCompressedData )

The opposite of CompressStringENC. encodedCompressedData contains the compressed data as an encoded string (hex, base64, etc) as specified by the EncodingMode property setting.

Returns a null on failure

# Returns a string
encodingMode( )

Controls the encoding expected by methods ending in "ENC", such as CompressBytesENC. Valid values are "base64", "hex", "url", and "quoted-printable". Compression methods ending in ENC return the binary compressed data as an encoded string using this encoding. Decompress methods expect the input string to be this encoding.

Returns a null on failure

# Returns a string
endCompressBytesENC( )

Must be callled to finalize a compression stream. Returns any remaining (buffered) compressed data.

(See BeginCompressBytesENC)

Returns a null on failure

# Returns a string
endCompressStringENC( )

Must be callled to finalize a compression stream. Returns any remaining (buffered) compressed data.

(See BeginCompressStringENC)

Returns a null on failure

# Returns a string
endDecompressString( )

Called to finalize the decompression stream and return any remaining (buffered) decompressed data.

(See BeginDecompressString)

Returns a null on failure

# Returns a string
endDecompressStringENC( )

Called to finalize the decompression stream and return any remaining (buffered) decompressed data.

The input to this method is an encoded string containing compressed data. The EncodingMode property should be set prior to calling this method. The input string is decoded according to the EncodingMode (hex, base64, etc.) and then decompressed.

(See BeginDecompressStringENC)

Returns a null on failure

# Returns a string
lastErrorHtml( )

Error information in HTML format for the last method called.

Returns a null on failure

# Returns a string
lastErrorText( )

Error information in plain-text format for the last method called.

Returns a null on failure

# Returns a string
lastErrorXml( )

Error information in XML format for the last method called.

Returns a null on failure

# data is a CkByteData object (output)
# Returns a string
moreCompressBytesENC( data )

(See BeginCompressBytesENC)

Returns a null on failure

# str is a string (input)
# Returns a string
moreCompressStringENC( str )

(See BeginCompressStringENC)

Returns a null on failure

# data is a CkByteData object (output)
# Returns a string
moreDecompressString( data )

(See BeginDecompressString)

Returns a null on failure

# str is a string (input)
# Returns a string
moreDecompressStringENC( str )

The input to this method is an encoded string containing compressed data. The EncodingMode property should be set prior to calling this method. The input string is decoded according to the EncodingMode (hex, base64, etc.) and then decompressed.

(See BeginDecompressStringENC)

Returns a null on failure

# Returns a string
version( )

A version string, such as "1.2.0"

Returns a null on failure