Edit report at https://bugs.php.net/bug.php?id=76093&edit=1
ID: 76093
Comment by: cananian at wikimedia dot org
Reported by: Wes dot nospam at example dot org
Summary: numfmt_format should accept string numbers rather
than casting to float
Status: Open
Type: Feature/Change Request
Package: I18N and L10N related
PHP Version: 7.2.3
Block user comment: N
Private report: N
New Comment:
I've added the followup which handles formatCurrency() to the same PR. So both patches are
there now.
Previous Comments:
------------------------------------------------------------------------
[2021-12-15 19:47:54] cananian at wikimedia dot org
github pr is now at https://github.com/php/php-src/pull/7782
Sorry for the long delay! It got lost in my tree for a while.
I have a followup for formatCurrency at https://github.com/cscott/php-src/tree/bug76093-followup
-- as currently written it required a new method in ICU, but as documented in https://unicode-org.atlassian.net/browse/ICU-21479
this can actually be done with the current ICU API in a certain way; I need to update the follow up
to do things That Way.
------------------------------------------------------------------------
[2021-09-16 13:02:39] cmb@php.net
> I have a patch written, I'll post it shortly.
Any update? Also, better submit a pull request[1] instead of
attaching a patch for better visibility.
[1] <https://github.com/php/php-src/pulls>
------------------------------------------------------------------------
[2021-01-28 20:39:09] cananian at wikimedia dot org
This is the root cause of Wikimedia bug T268456, fwiw: https://phabricator.wikimedia.org/T268456
I have a patch written, I'll post it shortly.
There's a similar issue with currency formatting, but that requires an upstream patch to
libicu: https://unicode-org.atlassian.net/browse/ICU-21479
------------------------------------------------------------------------
[2021-01-28 14:35:34] mail at lucaswerkmeister dot de
Hm, I donât see so many differences between General Decimal Arithmetic numeric strings [1] and
PHP numeric strings [2]:
1. PHP allows leading and trailing whitespace, GDA does not.
2. GDA includes special values (s)NaN and Inf(inity), PHP does not.
The syntax for finite numbers themselves is identical, as far as I can tell. (For instance, both
allow lower- and uppercase E in exponential notation, empty digits before xor after decimal
separator, only ASCII digits 0-9, leading zeroes anywhereâ¦) Maybe this was different before PHP
8âs improved numeric strings [3].
[1]: http://speleotrove.com/decimal/daconvs.html#refnumsyn
[2]: https://www.php.net/manual/en/language.types.numeric-strings.php
[3]: https://wiki.php.net/rfc/saner-numeric-strings
------------------------------------------------------------------------
[2021-01-22 21:02:20] cananian at wikimedia dot org
libicu has the code to create the Decimal Number for you.
You'd use https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1Formattable.html#a0505d26515fa1bbac3dd46a7e15e120e
to create a Formattable from the string input, and then call formatUFormattable() on that: https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/unum_8h.html#aec903c32ade7d632fb7125a5dfd667ea
Should be pretty straight-forward.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=76093
--
Edit this bug report at https://bugs.php.net/bug.php?id=76093&edit=1