PHP 4.0 Bug #9168 Updated: unpack 'h' and 'H' formats don't work
| From: | stas@php.net | Date: | Tue, 20 Mar 2001 10:45:58 +0000 |
| Subject: | PHP 4.0 Bug #9168 Updated: unpack 'h' and 'H' formats don't work | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-49471@lists.php.net to get a copy of this message | ||
ID: 9168
Updated by: stas
Reported By: rusty@socrates.berkeley.edu
Old-Status: Open
Status: Closed
Bug Type: Strings related
Assigned To:
Comments:
H and h doesn't work by nibbles, only by bytes (i.e., you
cannot really do unpack("H<n>z") when n is not even.
Otherwise, if you write unpack("Hz/C"), the C whould have to
start from half-byte, which is absurd.
Previous Comments:
---------------------------------------------------------------------------
[2001-02-07 18:56:38] rusty@socrates.berkeley.edu
In the following sample the variable "encoded" is zero length; an empty string. If I
change the format chars from H and h to C then it does get stuff.
<script language="php">
// 0xFF * 0xEE
$ch = 60690;
$encoded = "";
$hexn = unpack("Hz", $ch); // high nibble
if (isset($hexn["z"]))
$encoded .= $hexn["z"];
else
$encoded .= "-";
$hexn = unpack("hz", $ch); // low nibble
if (isset($hexn["z"]))
$encoded .= $hexn["z"];
else
$encoded .= "-";
echo $encoded . "<br>";
echo strlen($encoded) . "<br>";
</script>
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9168&edit=2