Topic: Issue with local and Number formats with remi's php implementation

Hi there !

At the company I work for, we've been using Centos 7 for a number of years to hosts the websites/application we develop. I've resisted for some reasons from using Remi's repo, so we've been using php from IUS' repo since a long time. Php 7.3, and now PHP 7.4 also, which I found at the time more inline with the way RHEL packages things.

But, that repo has no version of PHP 8, nor PHP 8.1, and probably won't. They also do not have any support for RHEL/CentOS/Rocky version 8. With the base OS, there is a module for PHP 7.4, but not yet fo PHP 8.0, nor PHP 8.1.

So, for Rocky Linux 8, and for PHP 8, I've turned to Remi's repo.

Now, I have face the first difference with the base os version of PHP 7.4 and remi's version of it.

This code :

<?php

print currency_format(1.23);
function currency_format(?float $price, ?string $currency = 'CAD', ?string $locale = null): string
{
    $locale = $locale ?? 'fr_CA' ;
    $formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
    return $formatter->formatCurrency($price, $currency);
}


Outputs on every implementation of PHP, either centos 7 base install, ius version of PHP 7.3, 7.4. With Rocky's base os module of PHP 7.4, etc.

1,23 $


But with Remi's version of PHP, I get :

1,23 $ CA

Wich is anoying and will break the display at many places...

What can be done for this ?

Re: Issue with local and Number formats with remi's php implementation

This behavior is related to libicu version used

EL-7 provides version 50.2
EL-8 provides version 60.3
EL-9 provides version 67.1

And PHP build in my repository always use version 69.1
for consistency, and to get benefit of modern version
(some updates were requested by users, especially for Unicode)

so "1,23 $ CA" seems the expected behavior

BTW, you can change default output defining your own, using setPattern or setTextAttributes

Ex:

$formatter->setTextAttribute(NumberFormatter::PAD_AFTER_PREFIX, " $")

Output will be "1,23 $"

And thus you code will be more portable on various distributions.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: Issue with local and Number formats with remi's php implementation

> With the base OS, there is a module for PHP 7.4, but not yet fo PHP 8.0, nor PHP 8.1.

CentOS 8 Stream already have 8.0 wink

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi