Trouble with std.zlib

Andrew Wiley wiley.andrew.j at gmail.com
Tue Jul 19 10:19:21 PDT 2011


On Tue, Jul 19, 2011 at 10:14 AM, Andrew Wiley <wiley.andrew.j at gmail.com>wrote:

> On Tue, Jul 19, 2011 at 9:57 AM, Jesse Phillips <
> jessekphillips+D at gmail.com> wrote:
>
>> Andrew Wiley Wrote:
>>
>> > I know, but if you look at the docs for the inflate functions, zlib is
>> > supposed to be autodetecting the gzip header and uncompressing the
>> payload
>> > correctly, if I understand the documentation (which I probably don't at
>> this
>> > point).
>>
>> Not sure what documentation you are talking of. But it doesn't sound like
>> it does auto detection, an answer to one of the question:
>>
>> "You can request that deflate write the gzip format instead of the zlib
>> format using deflateInit2(). You can also request that inflate decode the
>> gzip format using inflateInit2(). Read zlib.h for more details."
>>
>
> Ah, I stand corrected:
> "inflate() can decompress and check either zlib-wrapped or gzip-wrapped
>   deflate data.  The header type is detected automatically, if requested
> when
>   initializing with inflateInit2()."
>

Looks like this is the solution:
ubyte[] realarr = cast(ubyte[])uncompress(arr, 0, 47);
The 47 makes zlib autodetect the header (because the 32 bit is set; if you
wanted to force gzip, you'd set the 16 bit).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110719/138f0bac/attachment.html>


More information about the Digitalmars-d mailing list