zlib¶
This module uses zlib-binding to create a more idiomatic Open Dylan API to zlib.
Conditions¶
- <zlib-error> Class¶
Superclass of all error types signaled by the zlib library.
- <zlib-errno-error> Class¶
- Superclasses:
- <zlib-stream-error> Class¶
- Superclasses:
- See also:
See
$z-stream-error
.
- <zlib-data-error> Class¶
- Superclasses:
- See also:
See
$z-data-error
.
- <zlib-memory-error> Class¶
- Superclasses:
- See also:
See
$z-mem-error
.
- <zlib-buffer-error> Class¶
- Superclasses:
- See also:
See
$z-buf-error
.
- <zlib-version-error> Class¶
- Superclasses:
- See also:
See
$z-version-error
.
- <zlib-unexpected-error> Class¶
There was an unexpected error compressing or decompressing.
- Superclasses:
Compression / Uncompression¶
zlib-compress
¶
- zlib-compress Function¶
- Signature:
zlib-compress string #key level => (compressed)
- Parameters:
string – An instance of
<string>
. String to compress.level (#key) –
An instance of
<integer>
. A number between 0 and 9, from no compression to best compression. Use$z-best-speed
for best speed,$z-best-compression
for best compression.$z-no-compression
gives no compression at all. If absent, it uses$z-default-compression
as a compromise between speed and compression.- seealso:
- Example:
The following code compress a string with a
$z-default-compression
level.let phrase = "A horse, a horse, my kingdom for a horse"; let compressed = zlib-compress(phrase); format-out("Phrase size: %d Compressed size: %d\n", phrase.size, compressed.size);
Now we compress the string using the maximum compression level (
$z-best-compression
).let phrase = "Brevity is the soul of wit"; let compressed = zlib-compress(phrase, level: $z-best-compression);
zlib-uncompress
¶
- zlib-uncompress Function¶
Uncompress a previously compressed string.
- Signature:
zlib-uncompress compressed length => (string)
- Parameters:
- Values:
string – An instance of
<string>
. Uncompressed string.
- Example:
let phrase = "A horse, a horse, my kingdom for a horse"; let compressed = zlib-compress(phrase); let uncompressed = zlib-uncompress(compressed, phrase.size); format-out("Phrase: %s Uncompressed: %s\n", phrase, uncompressed);