Re: [PHP] gzuncompress() Not Working.

2007-11-07 Thread heavyccasey
In my tests, Python can parse both Adler-32 and CRC32, while PHP can only do Adler-32. Anyways, I shortened my function: function fixAdler32($data) { static $f; if (!isset($f)) $f = tempnam('/tmp', 'gz_fix'); file_put_contents($f, "\x1f\x8b\x

Re: [PHP] gzuncompress() Not Working.

2007-11-07 Thread heavyccasey
They're exactly the same, except of the last 4 bytes. Python calculates them differently than PHP. PHP follows the standards, Python does not :] This would be more concise if PHP included the gzdecode (http://us2.php.net/gzdecode) function. On Nov 7, 2007 12:12 AM, Per Jessen <[EMAIL PROTECTED]>

Re: [PHP] gzuncompress() Not Working.

2007-11-07 Thread Per Jessen
[EMAIL PROTECTED] wrote: > They're exactly the same, except of the last 4 bytes. Python > calculates them differently than PHP. PHP follows the standards, > Python does not :] That is exactly what is so weird - does Python maybe have its own implementation of the gzip compression algorithm? I w

Re: [PHP] gzuncompress() Not Working.

2007-11-07 Thread Per Jessen
[EMAIL PROTECTED] wrote: > The documentation for zlib says that it expects an Adler-32 checksum > at the end of the file. > > PHP follows this [largely outdated] standard. Uh, nothing to do with PHP, the code is in zlib. > Python, on the other hand, doesn't, and uses a different checksum, > CR

Re: [PHP] gzuncompress() Not Working.

2007-11-06 Thread heavyccasey
The documentation for zlib says that it expects an Adler-32 checksum at the end of the file. PHP follows this [largely outdated] standard. Python, on the other hand, doesn't, and uses a different checksum, CRC-32. That's why it won't decompress. But I've written my own function and it's working

Re: [PHP] gzuncompress() Not Working.

2007-11-06 Thread Per Jessen
[EMAIL PROTECTED] wrote: > Alright, I think I know the problem. > > PHP's gzuncompress uses the Adler-32 checksum at the end of the zlib, > while Python uses CRC32. > > Why must you follow the standards, PHP!? > > Does anyone know of any workaround? Are you saying that you've got compressed da

Re: [PHP] gzuncompress() Not Working.

2007-11-06 Thread heavyccasey
Alright, I think I know the problem. PHP's gzuncompress uses the Adler-32 checksum at the end of the zlib, while Python uses CRC32. Why must you follow the standards, PHP!? Does anyone know of any workaround? On Nov 6, 2007 7:03 AM, <[EMAIL PROTECTED]> wrote: > I left that empty. The decompres

Re: [PHP] gzuncompress() Not Working.

2007-11-06 Thread heavyccasey
I left that empty. The decompressed string is about 224 KB, so it shouldn't throw an error. Thanks for the reply! On Nov 6, 2007 12:25 AM, Per Jessen <[EMAIL PROTECTED]> wrote: > Casey wrote: > > > When I try gzuncompress() on the same data (I checked), it returns a > > "Data error". I also trie

Re: [PHP] gzuncompress() Not Working.

2007-11-06 Thread Per Jessen
Casey wrote: > When I try gzuncompress() on the same data (I checked), it returns a > "Data error". I also tried gzinflate() and many user-created gzdecode > () functions, with no luck. Did you specify a correct length for gzuncompress() ? >From the manpage: The function will return an error if

[PHP] gzuncompress() Not Working.

2007-11-05 Thread Casey
Hello, list! I'm trying to translate some code from Python to PHP so it will work on my server. The Python code is: x = zlib.decompressobj() x.decompress(blah) # blah is a 100KB string When I try gzuncompress() on the same data (I checked), it returns a "Data error". I also tried gzinflat