[php-src] Issue #10272: Latest intl and icu versions cause "breaking change" with Canadian currency display
| From: | victorjkhalaf | Date: | Mon, 09 Jan 2023 23:14:51 +0000 |
| Subject: | [php-src] Issue #10272: Latest intl and icu versions cause "breaking change" with Canadian currency display | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243384@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10272
Author: victorjkhalaf
### Description
The following code:
```php
<?php
$foreignCurrency = new NumberFormatter('en\_CA', NumberFormatter::**CURRENCY**);
$foreignCurrency->setAttribute(NumberFormatter::**FRACTION\_DIGITS**, 2);
echo $foreignCurrency->formatCurrency(109.99, 'CAD');
```
Resulted in this output:
```
CA$109.99
```
But I expected this output instead:
```
$109.99
```
We recently tried to bump up our php Alpine Linux Docker image to 8.2 and this change seems to have
been introduced with the
intl extension, specifically
NumberFormatter's formatCurrency call.
I dug into it pretty deeply as I could not find ANY posts or changelogs on PHP itself relating to
this. It SEEMS to be related to an update to the C ICU and CLDR libraries which, as I understand it,
are what the intl extension uses underneath to format numbers.
The ICU version I had when we ran Alpine 3.15 with php8.1 packages was 69.1 (identified via
php -i under the Internationalization section), while 3.16 with php8.2 uses 71.0.
That's when CLDR version 40+ was included based on the ICU github release notes. I was able to
find this info as well which hinted at possible changes.
https://github.com/unicode-org/cldr/pull/2366/files
and specifically this comment https://github.com/unicode-org/cldr/pull/2366#discussion_r977849111
The issue of course is this breaks our own implementation where we append the CAD suffix to prices
to identify CAD currencies.
I'm trying to figure out if there's a way to NOT include the alpha before the symbol, but
searching for how to write patterns reveals that the ¤ symbol in the pattern for en_CA
(¤#,##0.00) is what shows the dollar sign, as well as the alpha for Canadian locales.
We could just adapt our code and move to this standard, which is what I am leaning more on doing. I
just wanted to report this because it seems virtually no source online besides my one Reddit post on
PHPHelp mentions it. It's not so much a bug, I suppose, but it definitely is an unexpected
behaviour change. I understand the PHP maintainers may not be able to do anything about it since
it's done by the underlying C lib, but I wonder about documenting this at least?
### PHP Version
PHP 8.2.0
### Operating System
Alpine 3.16