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
In reply to Re: reversible pack()?
by tachyon
in thread reversible pack()?
by monsieur_champs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |