php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53113 number_format(): wrong usage of term "character" in multi-byte context
Submitted: 2010-10-20 13:41 UTC Modified: 2010-11-07 05:11 UTC
From: alex dot schuch at gmx dot de Assigned: kalle (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: -
Private report: No CVE-ID: None
 [2010-10-20 13:41 UTC] alex dot schuch at gmx dot de
Description:
------------
"Only the first character of thousands_sep is used. For example, if you use
& as thousands_sep on the number 1000, number_format() will return
1&000."

This example is based on US-ASCII or other one-byte character sets. If for
example the *single character* "ü" in UTF-8 is used, the byte-representation is
two byte (I might be wrong, but this is not relevant). The function
number_format() uses the *first byte* of that character, resulting in something
broken, like broken UTF-8.

Expected result:
----------------
Add the following note:
Multi-byte characters are *not*  supported in this function, as only the first byte
will be used, resulting in broken encoding.

Furthermore:
Only "thousands_sep" has this notice as of now, but according to my tests, the
same applies to "dec_point". So please add the note above there as well.

Actual result:
--------------
> php -r "var_dump(number_format(123456789.123, 4, 'ö', 'ä'));"
string(16) "123�456�789�1230"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-22 04:05 UTC] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=304600
Log: Fixed bug #53113 (number_format(): wrong usage of term "character" in multi-byte context)
 [2010-10-22 04:05 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2010-10-22 04:05 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2010-10-27 16:16 UTC] alex dot schuch at gmx dot de
The comment was only added for thousands_sep.

According to current version of PHP 5.3 branch, the same "issue" applies to "dec_point" as well. Please add the note to that parameter as well. Thanks.
 [2010-10-27 16:48 UTC] kalle@php.net
-Status: Closed +Status: Re-Opened
 [2010-11-07 05:11 UTC] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=305143
Log: Fixed bug #53113, round two
 [2010-11-07 05:11 UTC] kalle@php.net
-Status: Re-Opened +Status: Closed
 [2010-11-07 05:11 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:08 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=39ea8b6dafcd56a7a42ff73bbe3c38ad182f4088
Log: Fixed bug #53113, round two
 [2020-02-07 06:09 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=1312852e1486156f85a5e4c9ac0fafd3a8035c2e
Log: Fixed bug #53113 (number_format(): wrong usage of term "character" in multi-byte context)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 05:00:01 2026 UTC