php-src/ext/standard/tests/strings/pack_A.phpt
Gustavo André dos Santos Lopes dbc5b42435 pack() with new "Z" more in line with Perl.
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.
2012-04-17 22:21:32 +01:00

26 lines
357 B
PHP

--TEST--
pack()/unpack(): "A" modifier
--FILE--
<?php
var_dump(
pack("A5", "foo "),
pack("A4", "fooo"),
pack("A4", "foo"),
unpack("A*", "foo\0\rbar\0 \t\r\n"),
unpack("A4", "foo\0\rbar\0 \t\r\n")
);
?>
--EXPECTF--
string(5) "foo "
string(4) "fooo"
string(4) "foo "
array(1) {
[1]=>
string(8) "foo%c%cbar"
}
array(1) {
[1]=>
string(3) "foo"
}