#23894 [Ver]: sprinf format Problem
| From: | s dot masugata at digicom dot dnp dot co dot jp | Date: | Fri, 30 May 2003 13:39:28 +0000 |
| Subject: | #23894 [Ver]: sprinf format Problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-40713@lists.php.net to get a copy of this message | ||
ID: 23894
User updated by: s dot masugata at digicom dot dnp dot co dot jp
Reported By: s dot masugata at digicom dot dnp dot co dot jp
Status: Verified
Bug Type: Strings related
Operating System: RedHat Linux6.2J
PHP Version: 4.3.2
New Comment:
Thank you very much for Reply.
Since this function group is likely to be used quite extensively,
the influence range seems to be large.
A cause was not found although many things were investigated
individually.
I'm sorry that reporting is only always possible.
Previous Comments:
------------------------------------------------------------------------
[2003-05-30 08:28:58] s dot masugata at digicom dot dnp dot co dot jp
Similarly, neither vsprintf nor vprintf also operates.
<?
$A = -1;
$Array[0] = $A;
echo bin2hex( vsprintf( "%02d:", $Array ) );
vprintf( "%02d:", $Array );
?>
reslt:[2d31003a]
reslt:[-1]
4.1.2 or 4.3.1:
reslt:[2d313a]
reslt:[-1:]
------------------------------------------------------------------------
[2003-05-30 08:24:33] elmicha@php.net
No, it doesn't look like an environmental problem. sprintf() and
printf() indeed append an extra NUL character for negative numbers:
% LC_ALL=C php -r '
printf( "%03d\n", -1 );
' | xxd
0000000: 2d30 3100 0a -01..
It happens also with "%02f" format.
------------------------------------------------------------------------
[2003-05-30 08:22:08] s dot masugata at digicom dot dnp dot co dot jp
printf does not operate, either.
<?
$A = -1;
printf( "%02d:", $A );
?>
reslt:[-1]
4.1.2 or 4.3.1:
reslt:[-1:]
------------------------------------------------------------------------
[2003-05-30 05:12:17] s dot masugata at digicom dot dnp dot co dot jp
Operation of sprintf is amusing.
<?
$A = -1;
echo bin2hex( sprintf( "%02d:", $A ) );
phpinfo( );
?>
reslt:[2d31003a]
NULL is added.
It's satisfactory at 4.1.2 or 4.3.1.
An environmental problem?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23894&edit=1