ID: 36148
User updated by: andy at advancethermal dot com
Reported By: andy at advancethermal dot com
-Status: Bogus
+Status: Open
Bug Type: Unknown/Other Function
Operating System: WinXP, Win2k3
PHP Version: 5.1.2
New Comment:
Upon further testing, I found the following:
CODE:
$values = array("a", "aa", "aaa", "aaaa");
foreach ($values as $value) {
$a = pack("H*", $value);
$b = unpack("H*", $a);
echo "<p>".$value.": ";
var_dump($b);
}
ACTUAL RESULT:
a: array(1) { [1]=> string(3) "a00" }
aa: array(1) { [1]=> string(3) "aa0" }
aaa: array(1) { [1]=> string(5) "aaa00" }
aaaa: array(1) { [1]=> string(5) "aaaa0" }
EXPECTED RESULT: (produced from PHP 5.0.5)
a: array(1) { [1]=> string(2) "a0" }
aa: array(1) { [1]=> string(2) "aa" }
aaa: array(1) { [1]=> string(4) "aaa0" }
aaaa: array(1) { [1]=> string(4) "aaaa" }
The release notes for 5.1.2 indicate that the problem was fixed,
however this does not appear to be the case -- or is a new problem.
All scripts that handle binary data using unpack() had to be modified
with substr($unpackeddata[1], 0, -1) so it would be properly handled.
Previous Comments:
------------------------------------------------------------------------
[2006-01-25 00:32:56] [EMAIL PROTECTED]
See bug #35817.
------------------------------------------------------------------------
[2006-01-25 00:10:45] andy at advancethermal dot com
Sorry, reverse the Expected and Actual Results...
------------------------------------------------------------------------
[2006-01-25 00:09:59] andy at advancethermal dot com
Description:
------------
unpack("H*hex", $data) is adding an unexpected extra character to the
end of the string. Upgraded to PHP 5.1.2 using Windows Zip package.
Reproduce code:
---------------
echo "<p>".unpack("H*hex", file_get_contents("c:/php/php.exe"));
Try in 5.0.5 and 5.1.2 -- there is a difference.
Expected result:
----------------
...fff90
Actual result:
--------------
...fff9
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36148&edit=1