Used when the data to be compressed is not all in one buffer.
Used when the data to be decompressed is not all in one buffer.
Errors throw a ZlibException.
the header format the compressed stream is wrapped in
Compute the Adler-32 checksum of a buffer's worth of data.
Compress data
Compute the CRC32 checksum of a buffer's worth of data.
Decompresses the data in srcbuf[].
If you have a small buffer you can use compress and uncompress directly.
import std.zlib; auto src = "the quick brown fox jumps over the lazy dog\r the quick brown fox jumps over the lazy dog\r"; ubyte[] dst; ubyte[] result; dst = compress(src); result = cast(ubyte[]) uncompress(dst); assert(result == src);
When the data to be compressed doesn't fit in one buffer, use Compress and UnCompress.
import std.zlib; import std.stdio; import std.conv : to; import std.algorithm.iteration : map; UnCompress decmp = new UnCompress; foreach (chunk; stdin.byChunk(4096).map!(x => decmp.uncompress(x))) { chunk.to!string.write; }
References: Wikipedia
Copyright The D Language Foundation 2000 - 2011.
Compress/decompress data using the zlib library.