in reply to reversible pack()?
If you convert ASCII text with say 80 used chars into gzipped hex where you effectively drop yourself down to a 16 char alphabet but still in the (extended) ASCII 8 bit space you need 5x compression just to break even. This is close to the max compression you expect with gzip on text so this is kinda pointless. Normally you pack your ~ 80 char alphabet into a 256 slot 8 bit binary space. This is where a significant part of the compression comes from - using all the available bits efficiently. Hex is not the go.
[root@devel3 root]# cat test.pl #!/usr/bin/perl use Compress::Zlib; my $str = "Hello World!"; my $gzip = Compress::Zlib::memGzip( $str ); my $hex_enc = unpack 'H*', $gzip; my $hex_dec_gzip = pack 'H*', $hex_enc; my $str_dec = Compress::Zlib::memGunzip( $hex_dec_gzip ); print " $str $hex_enc $str_dec "; [root@devel3 root]# ./test.pl Hello World! 1f8b0800000000000003f348cdc9c95708cf2fca49510400a31c291c0c000000 Hello World! [root@devel3 root]#
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reversible pack()?
by jonadab (Parson) on Feb 10, 2004 at 22:31 UTC | |
|
Re: Re: reversible pack()?
by monsieur_champs (Curate) on Feb 11, 2004 at 12:39 UTC | |
by tachyon (Chancellor) on Feb 11, 2004 at 13:49 UTC |