#27384 [Bgs->Csd]: Function unpack incorrectly works with string with just one char

From: Date: Tue, 24 Feb 2004 21:45:24 +0000
Subject: #27384 [Bgs->Csd]: Function unpack incorrectly works with string with just one char
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-55485@lists.php.net to get a copy of this message
 ID:               27384
 Updated by:       sniper@php.net
 Reported By:      hayk at mail dot ru
-Status:           Bogus
+Status:           Closed
 Bug Type:         Unknown/Other Function
 Operating System: Windows 2000
 PHP Version:      4.3.4


Previous Comments:
------------------------------------------------------------------------

[2004-02-24 16:45:10] sniper@php.net

Because that's correct. RTFM.



------------------------------------------------------------------------

[2004-02-24 16:42:55] gschlossnagle@php.net

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

I see what you're saying now.  This has been fixed in 
HEAD.

------------------------------------------------------------------------

[2004-02-24 15:42:38] hayk at mail dot ru

Why this code works fine?
<?
	$sp = chr(0x20);
	$a = unpack('C2', $sp.$sp);
?>
<pre>
<? print_r($a); ?>
</pre>
We get:
Array
(
    [1] => 32
    [2] => 32
)

------------------------------------------------------------------------

[2004-02-24 15:30:15] gschlossnagle@php.net

You're not using unpack correctly.  The format string is

Type.Multiplicity.Name

Name cannot begin with or be a number, as it would be 
impossible to distinguish multiplicty from name.

------------------------------------------------------------------------

[2004-02-24 15:23:26] hayk at mail dot ru

I muddle up "Expected" and "Actual" results in the my submission.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/27384

-- 
Edit this bug report at http://bugs.php.net/?id=27384&edit=1


Thread (13 messages)

« previous php.bugs (#55485) next »