[php-src] Issue #20320: locale_canonicalize unexpected behavior (no level 2 canonicalization)
| From: | AllenJB | Date: | Tue, 28 Oct 2025 18:06:51 +0000 |
| Subject: | [php-src] Issue #20320: locale_canonicalize unexpected behavior (no level 2 canonicalization) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251140@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/20320
Author: AllenJB
### Description
I was attempting to document locale_canonicalize when I encountered unexpected behavior.
Specifically, the level 2 canonicalization doesn't appear to be performed.
If I [run the code below on 3v4l.org](https://3v4l.org/FCZki) I get the expected result (correct
currency canonicalization using level 2 rules), but on both my Windows 11 and Gentoo Linux servers
(both PHP 8.4) the level 2 canonicalization doesn't appear to be performed.
My best guess is this is related to ICU version. Using the Windows download archive ( https://windows.php.net/downloads/releases/archives/
) I found that PHP 7.2.9, using ICU 62.1, gives the expected result (the same as 3v4l's PHP 8.4
on 63.1), but PHP 7.3.9 using ICU 64.2 gives the unexpected result (no canonicalization of PREEURO).
The following code:
```php
<?php
echo locale_canonicalize('fr-FR@PREEURO') . "\n";
echo "Data Version: " . INTL_ICU_DATA_VERSION . "\n";
echo "ICU Version: ". INTL_ICU_VERSION . "\n";
```
Resulted in this output:
```
fr_FR_PREEURO
Data Version: 77.1
ICU Version: 77.1
```
But I expected this output instead:
```
fr_FR@currency=FRF
Data Version: 77.1
ICU Version: 77.1
```
### PHP Version
```plain
PHP 8.4.11 (cli) (built: Jul 29 2025 18:02:29) (NTS Visual C++ 2022 x64)
Copyright (c) The PHP Group
Zend Engine v4.4.11, Copyright (c) Zend Technologies
```
### Operating System
n/a