|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-04-28 08:46 UTC] phpbug at drque dot net
Description:
------------
When unpacking hex with 'unpack', a "0" is appended to the end of the resulting string. This did not happen in previous versions (this code functions in PHP 5.1.1).
A quick fix can be done by commenting out line 695 in "ext/standard/pack.c":
Change
len -= argb % 2;
to
//len -= argb % 2;
This line is one of 6 differences in "pack.c" between version 5.1.1 and 5.1.2. I wasn't able to understand why the "len -= argb %2" line was added.
Reproduce code:
---------------
<?php
$HexString = 'c45dc988443fa8fff52ce7953bf049b8';
$PackedHexString = pack( "h*" , $HexString );
$UnpackedHex =
unpack( "h*Hex" , $PackedHexString );
$UnpackedHex = $UnpackedHex[ 'Hex' ];
echo "$HexString\n";
echo "$UnpackedHex\n";
?>
Expected result:
----------------
c45dc988443fa8fff52ce7953bf049b8
c45dc988443fa8fff52ce7953bf049b8
Actual result:
--------------
c45dc988443fa8fff52ce7953bf049b8
c45dc988443fa8fff52ce7953bf049b80
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 15:00:02 2025 UTC |
PHP 5.1-200605011230 does work fine. Seems the area in question in "ext/standard/pack.c" has been changed to: if (argb > 0) { len -= argb % 2; } Thank you Mike