php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49398 number_format returns invalid character with some charsets
Submitted: 2009-08-28 12:46 UTC Modified: 2009-08-29 00:24 UTC
From: mark dot j dot wade at googlemail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.10 OS: Linux
Private report: No CVE-ID: None
 [2009-08-28 12:46 UTC] 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( 9999, 0, $locale['decimal_point'], $locale['thousands_sep'] );

Expected result:
----------------
9 999

Actual result:
--------------
9?999

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-29 00:24 UTC] jani@php.net
Thank you for not searching before submitting another bogus bug. See 
also bug #44041
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC