Skip to content

NumberFormatter currency output format changed (ICU issue?) #17218

@xHeaven

Description

@xHeaven

Description

The following code:

<?php
$fmt = new NumberFormatter( 'en_US', NumberFormatter::CURRENCY );
echo $fmt->formatCurrency(1234567.891234567890000, "EUR")."\n";
echo $fmt->formatCurrency(1234567.891234567890000, "HUF")."\n";

$fmt = new NumberFormatter( 'de_DE', NumberFormatter::CURRENCY );
echo $fmt->formatCurrency(1234567.891234567890000, "EUR")."\n";
echo $fmt->formatCurrency(1234567.891234567890000, "HUF")."\n";

$fmt = new NumberFormatter( 'hu_HU', NumberFormatter::CURRENCY );
echo $fmt->formatCurrency(1234567.891234567890000, "EUR")."\n";
echo $fmt->formatCurrency(1234567.891234567890000, "HUF")."\n";

Resulted in this output:

€1,234,567.89
HUF 1,234,567.89
€ 1,234,567.89
HUF 1,234,567.89
€ 1,234,567.89
HUF 1,234,567.89

But I expected this output instead:

€1,234,567.89
HUF 1,234,567.89
1.234.567,89 €
1.234.567,89 HUF
1 234 567,89 EUR
1 234 567,89 Ft

Is this something with the ICU project? I've tested with 2 different systems, one being Alpine Linux v3.21 x86_64 with PHP 8.4.1 and another being Ubuntu 22.04 LTS with PHP 8.3.11.

On the Alpine system, my icu-libs version is 74.2, on the Ubuntu system my libicu version is 70.1.

Edit: I've tried to compile the same (70.1) version of ICU from source on my Alpine system, but either I'm doing something wrong, or it doesn't matter which version I'm using on my system - which would make no sense, because it works perfectly on 3v4l on PHP 8.4.1.

This is my php -i | grep ICU output though, PHP doesn't give a flying one what's on my system. Any advice?

ICU version => 74.2
ICU Data version => 74.2
ICU TZData version => 2023c
ICU Unicode version => 15.1

PHP Version

PHP 8.4.1

Operating System

Alpine Linux v3.21 x86_64

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions