Bug #76202 [Nab]: \NumberFormatter::getSymbol() returns wrong international currency symbol
| From: | requinix@php.net | Date: | Mon, 09 Apr 2018 16:42:17 +0000 |
| Subject: | Bug #76202 [Nab]: \NumberFormatter::getSymbol() returns wrong international currency symbol | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214669@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76202&edit=1
ID: 76202
Updated by: requinix@php.net
Reported by: a dot schilder at gmx dot de
Summary: \NumberFormatter::getSymbol() returns wrong
international currency symbol
Status: Not a bug
Type: Bug
Package: I18N and L10N related
Operating System: Windows 10
PHP Version: 7.2.4
Block user comment: N
Private report: N
New Comment:
Whether MRU or MRO is correct depends on which ICU you have: MRO is correct for ICU <61, MRU is
correct for ICU >=61. I mean, it's working as expected in both versions, it's just that
one is now out of date.
I didn't notice you said this was on Windows. The current Windows version of PHP 7.2(.4) from a
couple weeks ago bundles ICU 60, so it is being kept up to date and it's quite likely that the
next release will have ICU 61.
Previous Comments:
------------------------------------------------------------------------
[2018-04-09 16:28:27] a dot schilder at gmx dot de
Thank you very much, that clarified it.
In the ICU documentation I read that the ISO currency code is used ("In ICU and Java, the
currency is specified in the form of a 3-letter ISO 4217 code.") and therefore it's what I
expected.
I didn't know that ICU relies completely on the CLDR and their updates. Also, following the
introduction for the intl extension, PHP not only uses the ICU data, but also other data (for
example the Olson timezone DB). So for me it wasn't clear, if the value is correct (based on
the lib version) or not.
------------------------------------------------------------------------
[2018-04-09 15:07:19] requinix@php.net
PHP's intl functionality comes from the ICU project. http://site.icu-project.org/
Their information comes from the CLDR project. http://cldr.unicode.org/index
The currency change to MRU is included in the most recent CLDR 33: http://cldr.unicode.org/index/downloads/cldr-33
> Addition of new currency code MRU for Mauritania; replaces MRO.
That is included in ICU 61: http://site.icu-project.org/download/61
> ICU 61 upgrades to CLDR 33 locale data,
and they also mention
> New currency code MRU for Mauritania.
So you have to check your system's copy of libicu or whatever it's called and see where
you're at. Given it was released only a couple weeks ago, if you want to run the latest and
greatest rules then you'll probably need to build yourself a copy of libicu from the ICU4C
source.
With that copy built and installed on your system correctly, PHP and intl should show you
"MRU".
As for the docs, the intro page does talk about ICU and includes a couple links. Is there something
else you'd like to see there?
------------------------------------------------------------------------
[2018-04-09 14:46:45] a dot schilder at gmx dot de
Description:
------------
In my tests I recognized that the currency code for Mauritania returned by
\NumberFormatter::getSymbol() is 'MRO', although it was changed to 'MRU' from
Janauary 1st 2018 (see: https://www.currency-iso.org/dam/isocy/downloads/dl_currency_iso_amendment_165.pdf).
If you look into the Unicode CLDR, the code there is still set to 'MRO', so the question
for me is: What is used as the base for the 'international currency symbol'? When
it's ISO 4217 (as I'd expect), the code returned is wrong and should be corrected. If
it's based on the Unicode CLDR data, the code is (currently) correct - but unexpected.
In any case the used base for the currency symbol should be documented - so feel free to change this
to a documentation bug if the Unicode data are used.
Test script:
---------------
<?php
$formatter = new \NumberFormatter('*_MR', \NumberFormatter::CURRENCY);
$currency = $formatter->getSymbol(\NumberFormatter::INTL_CURRENCY_SYMBOL);
echo $currency;
Expected result:
----------------
MRU
Actual result:
--------------
MRO
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76202&edit=1