开发者

How to read a char[] object into a tango.io.compress.ZlibStream?

I have a D program with Tango and I'm trying to uncompress a gzipped string. Unfortunately I don't have A stream to it, but the compressed data is stored in a char[]. How can I uncompress it using tangos tango.io.compress.ZlibStream? I need another char[] with the uncompressed data.

I've been trying this for hours now. I'm not very familiar with tango.

Thank you

Edit: my code looks something like this:

cha开发者_如何学运维r[] rawData; // decoded data goes here
Array array = new Array(e.value[4..(e.value.length-3)]); // e.value is a char[]
// array slice, castet to char[] is "H4sIAAAAAAAAA2NkYGBgHMWDBgMAjw2X0pABAAA="
// array.readable returns 40 (matches the above string)
// decoded string is expected to be 33 repeatitions of "AQAAAAEAAAABAAAA"
// followed by "AQAAAA=="
auto reader = new ZlibInput(array);
ubyte[1024] buffer;
reader.read(buffer); // throws Z_DATA_ERROR


well, nevermind. It appears, the guy who designed this file format compressed the data, before he encoded it with base64. I tried to decompress still base64 encoded data.

When I decoded the string with base64 and used gzip on the resulting ubyte array, it did the trick!

sorry about that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜