ID: 39588 Updated by: [EMAIL PROTECTED] Reported By: pprasse at actindo dot de -Status: Open +Status: Bogus -Bug Type: Scripting Engine problem +Bug Type: Strings related Operating System: linux 2.6.10 PHP Version: 4.4.4 New Comment:
Expected behaviour. $var = "str"; $packed = pack("a5", $var); // 5 bytes long NULL-padded string var_dump(unpack("a*", $packed)); // the NULL-padding is removed to get the original data. Previous Comments: ------------------------------------------------------------------------ [2006-11-22 14:09:26] pprasse at actindo dot de Description: ------------ unpack( "a*", $string ) does not work as expected when last character of $string is "\0" Reproduce code: --------------- <?php $string = "abc\0"; $arr = unpack( "a*buf", $string ); printf( "strlen = %d\n", strlen($arr['buf']) ); printf( "hex dump:\t" ); for( $i=0; $i<strlen($arr['buf']); $i++ ) printf( " %02x", ord($arr['buf']{$i}) ); printf( "\n" ); ?> Expected result: ---------------- strlen = 4 hex dump: 61 62 63 00 Actual result: -------------- strlen = 3 hex dump: 61 62 63 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39588&edit=1