Re: gzuncompress() Not Working.

From: Date: Wed, 07 Nov 2007 07:28:26 +0000
Subject: Re: gzuncompress() Not Working.
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-264165@lists.php.net to get a copy of this message
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 now. :) function fixAdler32($data) { $tempnam = tempnam('/tmp', 'gzfix'); $fh = fopen($tempnam, 'wb'); fwrite($fh, "\x1f\x8b\x08\x00\x00\x00\x00\x00" . $data); fclose($fh); $dat = ''; $gz = gzopen($tempnam, 'rb'); if ($gz == false) die('Error opening temporary GZ file.'); do { $dat .= gzread($gz, 100000); } while (!feof($gz)); gzclose($gz); unlink($tempnam); return $dat; } On Nov 6, 2007 11:07 PM, Per Jessen <per@computer.org> wrote: > heavyccasey@gmail.com 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 data in one format by Python > that cannot be uncompressed by PHP because it expects another format? > > > > /Per Jessen, Zürich > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#264165) next »