#49398 [NEW]: number_format returns invalid character with some charsets

2009-08-28 Thread mark dot j dot wade at googlemail dot com
From: mark dot j dot wade at googlemail dot com
Operating system: 
PHP version:  5.2.10
PHP Bug Type: Strings related
Bug description:  number_format returns invalid character with some charsets

Description:

number_format will only accept a single character for the thousands 
separator and deliberately shortens longer input to one character.

However, for some charsets (ru_RU.UTF8 was the one I discovered this on) 
the thousands separator as returned by localeconv is more than one 
character.
Normally, this wouldn't be a problem, however, it seems when PHP tries 
to shorten this particular value to one character, it creates an invalid 
character and returns something like demonstrated in the reproduce code.

Reproduce code:
---
setlocale( L_ALL, 'ru_RU.UTF8' );
$locale = localeconv(); 
echo number_format( , 0, $locale['decimal_point'],
$locale['thousands_sep'] );

Expected result:

9 999

Actual result:
--
9?999

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



#49398 [Fbk-Opn]: number_format returns invalid character with some charsets

2009-08-28 Thread mark dot j dot wade at googlemail dot com
 ID:  49398
 User updated by: mark dot j dot wade at googlemail dot com
 Reported By: mark dot j dot wade at googlemail dot com
-Status:  Feedback
+Status:  Open
 Bug Type:Strings related
 PHP Version: 5.2.10
 New Comment:

Linux


Previous Comments:


[2009-08-28 12:48:25] paj...@php.net

Which OS?



[2009-08-28 12:46:48] mark dot j dot wade at googlemail dot com

Description:

number_format will only accept a single character for the thousands 
separator and deliberately shortens longer input to one character.

However, for some charsets (ru_RU.UTF8 was the one I discovered this
on) 
the thousands separator as returned by localeconv is more than one 
character.
Normally, this wouldn't be a problem, however, it seems when PHP tries

to shorten this particular value to one character, it creates an
invalid 
character and returns something like demonstrated in the reproduce
code.

Reproduce code:
---
setlocale( L_ALL, 'ru_RU.UTF8' );
$locale = localeconv(); 
echo number_format( , 0, $locale['decimal_point'],
$locale['thousands_sep'] );

Expected result:

9 999

Actual result:
--
9?999





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