From:             
Operating system: Ubuntu
PHP version:      5.3.10
Package:          Output Control
Bug Type:         Bug
Bug description:%c format code ignores width specification

Description:
------------
Nothing unique about my configuration; I've tried this on several
different
machines with different PHP versions and received the same result.

When I attempt to use the %c formatting code with (for example,
sprintf()),
it ignores any width specifier that I indicate, as in the example code
below.

I saw nothing in the documentation that the %c code would not react to a
width
specifier any differently than the other data formats.

Test script:
---------------
<pre>
<?php 

$x = ord('A');

echo sprintf("|%c|\n",$x);
echo sprintf("|%1c|\n",$x);
echo sprintf("|%2c|\n",$x);
echo sprintf("|%3c|\n",$x);
echo sprintf("|%4c|\n",$x);
echo sprintf("|%5c|\n",$x);
echo sprintf("|%6c|\n",$x);
echo sprintf("|%7c|\n",$x);
echo sprintf("|%-8c|\n\n\n",$x);

?>

Expected result:
----------------
|A|
|A|
| A|
|  A|
|   A|
|    A|
|     A|
|      A|
|A       |


(I expected this because this is what the equivalent code in C produces)

Actual result:
--------------
|A|
|A|
|A|
|A|
|A|
|A|
|A|
|A|
|A|

-- 
Edit bug report at https://bugs.php.net/bug.php?id=61626&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=61626&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=61626&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=61626&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=61626&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=61626&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=61626&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=61626&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=61626&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=61626&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=61626&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=61626&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=61626&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=61626&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=61626&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=61626&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=61626&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=61626&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=61626&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=61626&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=61626&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=61626&r=mysqlcfg

Reply via email to