php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76202 \NumberFormatter::getSymbol() returns wrong international currency symbol
Submitted: 2018-04-09 14:46 UTC Modified: 2018-04-09 16:42 UTC
From: a dot schilder at gmx dot de Assigned:
Status: Not a bug Package: I18N and L10N related
PHP Version: 7.2.4 OS: Windows 10
Private report: No CVE-ID: None
 [2018-04-09 14:46 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-04-09 15:07 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2018-04-09 15:07 UTC] 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 16:28 UTC] 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 16:42 UTC] requinix@php.net
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.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Aug 08 21:01:26 2020 UTC