mirror of
https://github.com/php/php-src.git
synced 2024-09-27 21:07:25 +00:00
dbc5b42435
Made pack() with "Z" force NUL termination, even if it mean truncating input to less than the number of characters specified and if the number of characters is "*", the output will be one byte larger than the input. Improved tests.
28 lines
433 B
PHP
28 lines
433 B
PHP
--TEST--
|
|
pack()/unpack(): "Z" format
|
|
--FILE--
|
|
<?php
|
|
var_dump(
|
|
pack("Z0", "f"),
|
|
pack("Z5", "foo\0"),
|
|
pack("Z4", "fooo"),
|
|
pack("Z4", "foo"),
|
|
pack("Z*", "foo"),
|
|
unpack("Z*", "foo\0\rbar\0 \t\r\n"),
|
|
unpack("Z9", "foo\0\rbar\0 \t\r\n")
|
|
);
|
|
--EXPECTF--
|
|
string(0) ""
|
|
string(5) "foo%c%c"
|
|
string(4) "foo%c"
|
|
string(4) "foo%c"
|
|
string(4) "foo%c"
|
|
array(1) {
|
|
[1]=>
|
|
string(3) "foo"
|
|
}
|
|
array(1) {
|
|
[1]=>
|
|
string(3) "foo"
|
|
}
|