PYTHON gzinflate

is this article helpful?
|
Python replacement for PHP's gzinflate [ edit | history ]
#!/usr/bin/env python
# coding: utf-8

import zlib
import base64

def gzinflate(base64_string):
    compressed_data = base64.b64decode(base64_string)
    return zlib.decompress(compressed_data, -15)

PHP gzinflate

PHP original manual for gzinflate [ show | php.net ]

gzinflate

(PHP 4 >= 4.0.4, PHP 5)

gzinflateInflate a deflated string

Description

string gzinflate ( string $data [, int $length= 0 ] )

This function inflate a deflated string.

Parameters

data

The data compressed by gzdeflate().

length

The maximum length of data to decode.

Return Values

The original uncompressed data or FALSE on error.

The function will return an error if the uncompressed data is more than 32768 times the length of the compressed input data or more than the optional parameter length .

Examples

Example #1 gzinflate() example

<?php
$compressed   
gzdeflate('Compress me'9);
$uncompressed gzinflate($compressed);
echo 
$uncompressed;
?>

See Also