php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78056 Wrong currency format for nl_BE with money_format
Submitted: 2019-05-23 14:09 UTC Modified: 2019-05-23 15:04 UTC
From: wesley at weha dot be Assigned:
Status: Not a bug Package: Strings related
PHP Version: 7.3.5 OS: Centos 7.6
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wesley at weha dot be
New email:
PHP Version: OS:

 

 [2019-05-23 14:09 UTC] wesley at weha dot be
Description:
------------
When I use nl_BE locale I get the wrong format for negative values.
-1234.56 should be € -1 234,56
money_format gives this: € 1 234,56-

I'm sorry if anything is filled in wrong, first time here.

thank you.

Test script:
---------------
setlocale(LC_ALL, 'nl_BE.UTF-8')
echo money_format('%.2n','-1234.56');


Expected result:
----------------
€ -1 234,56

Actual result:
--------------
€ 1 234,56-

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-23 14:25 UTC] requinix@php.net
-Summary: Wrong currency format for nl_BE +Summary: Wrong currency format for nl_BE with money_format -Status: Open +Status: Not a bug -Package: Unknown/Other Function +Package: Strings related
 [2019-05-23 14:25 UTC] requinix@php.net
The output of money_format is controlled by your system's strfmon(3) function, not PHP.

Looks like your locale settings are way out of date: CLDR 26 (the relevant standard for this stuff) is the last time the NL locale was set to use the "¤ #,##0.00-" format, and CLDR 27 changed it to "¤ -#,##0.00" - that was back in 2015.

Update your system and/or locale settings.
 [2019-05-23 14:45 UTC] sjon@php.net
I actually have the exact same output on my completely up-to-date machine. It seems this is controlled by glibc, and I have 2.29-1 installed which is the latest version.

I can confirm requinix's observation (looking at) http://www.unicode.org/cldr/charts/27/summary/nl.html

However, nl_BE LC_MONETARY is an alias to nl_NL and /usr/share/i18n/locales/nl_NL has n_sign_posn=2 - which according to https://www.gnu.org/software/libc/manual/html_node/Sign-of-Money-Amount.html means: print minus sign after number.

So this might be a glibc bug?
 [2019-05-23 15:04 UTC] requinix@php.net
Oh yes, forgot glibc does locale its own way...

Yup, looking at the glibc source
  https://sourceware.org/git/?p=glibc.git;a=tree;f=localedata/locales;hb=refs/heads/master
they have nl_BE copying from nl_NL which has n_sign_pos=2.

So it's an upstream bug. https://www.gnu.org/software/libc/bugs.html
 [2019-05-23 15:07 UTC] sjon@php.net
I've reported this to glibc as https://sourceware.org/bugzilla/show_bug.cgi?id=24614
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC