|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-02-07 18:56 UTC] rusty at socrates dot berkeley dot 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>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 05:00:01 2025 UTC |
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.