|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-01-13 14:46 UTC] mortenskyt at gmail dot com
Description:
------------
In PHP 5.3.5, giving float point values to numfmt_format doesn't work when
setlocale is set to a country using comma instead of dot in floating point.
Also does not work in PHP 5.3.4 (FreeBSD)
DOES work on 5.3.3 (FreeBSD)
Perhaps interesting notes from my configuration:
intl
Internationalization support => enabled
version => 1.1.0
ICU version => 4.6
Directive => Local Value => Master Value
intl.default_locale => no value => no value
intl.error_level => 0 => 0
Test script:
---------------
<?php
$fmt = numfmt_create("da_DK", \NumberFormatter::CURRENCY);
echo numfmt_format($fmt, 5.5)."\n";
setlocale(LC_ALL, "da_DK.UTF-8");
echo numfmt_format($fmt, 5.5)."\n";
echo numfmt_format($fmt, "5,5")."\n";
Expected result:
----------------
5,50 kr
5,50 kr
5,00 kr
Actual result:
--------------
5,50 kr
NaN
5,00 kr
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 11:00:02 2025 UTC |
The exact same thing happens on all Debian Squeeze installations, given that php5- intl bundle is installed from the default debian package sources. The error appears right after switching locale to something other than default ("en", presumably) and trying to format a number with a comma using NumberFormatter. I was able to fix the issue on Debian Lenny by manually downgrading ICU library to 3.8 but ICU 3.8 does not work on Squeeze which raises importance of this issue even more.I can reproduce this with PHP 5.3.10 on Ubuntu 12.04 64. It is strange for me, because running from CLI works as expected. Code to run: $f = new NumberFormatter('hu_HU', NumberFormatter::PERCENT, '#,##0%'); echo $f->format(0.26) . "\n";PHP Version 5.5.29-1 ICU version 4.4.1 $fmt = new \NumberFormatter("de_DE", \NumberFormatter::DECIMAL); $fmt->format(23.25); Returns NaN