PHP 4.0 Bug #6361 Updated: unpack fails with 'H'

From: Date: Sun, 17 Sep 2000 21:08:44 +0000
Subject: PHP 4.0 Bug #6361 Updated: unpack fails with 'H'
Groups: php.dev 
Request: Send a blank email to php-dev+get-33439@lists.php.net to get a copy of this message
ID: 6361 Updated by: stas Reported By: alex@iniciando.com Status: Closed Bug Type: *General Issues Assigned To: Comments: Should be fixed in CVS, please check. Previous Comments: --------------------------------------------------------------------------- [2000-08-31 09:29:37] stas@php.net Well, PHP unpack seems to behave differently from perl's unpack here. In Perl, number behind H is the number of nibbles, in PHP - number of characters (which is different for the unpack). I don't know if this is an intended behaviour... --------------------------------------------------------------------------- [2000-08-25 19:04:23] alex@iniciando.com This script fails complaining about there isn't enougth data for unpack: $md5_val = '0123456789abcdef0123456789abcdef'; print "{$md5_val}<br>n"; $binary_md5 = pack('H32', $md5_val); $md5_val = unpack('H32a', $binary_md5); $md5_val = $md5_val['a']; print "{$md5_val}<br>n"; It's corresponding perl scripts works fine: #!/usr/bin/perl $md5_val = '0123456789abcdef0123456789abcdef'; print "$md5_valn"; $binary_md5 = pack('H32', $md5_val); ($md5_val) = unpack('H32', $binary_md5); print "$md5_valn"; Workarround: $md5_val = unpack('H32a', $binary_md5.$binary_md5); --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=6361

« previous php.dev (#33439) next »