Edit report at https://bugs.php.net/bug.php?id=55290&edit=1
ID: 55290
Comment by: franssen dot roland at gmail dot com
Reported by: franssen dot roland at gmail dot com
Summary: \NumberFormatter::parseCurrency() fails
Status: Open
Type: Bug
Package: I18N and L10N related
Operating System: Linux
PHP Version: 5.3.6 - 5.3.8
Block user comment: N
Private report: N
New Comment:
Tested the example code once more (copy-paste) on PHP 5.4.10 (ICU version
4.4.1, ICU Data version 4.4.0.1).
It still fails :') Also re-typing the code didnt help;
<?php
$fmt = numfmt_create('de_DE', NumberFormatter::CURRENCY);
$num = '1.234.567,89 $';
$curr = null;
echo 'We have ' . numfmt_parse_currency($fmt, $num, $curr) . ' in ' . $curr .
PHP_EOL;
echo PHP_EOL;
$fmt = new NumberFormatter('de_DE', NumberFormatter::CURRENCY);
$num = '1.234.567,89 $';
$curr = null;
echo 'We have ' . $fmt->parseCurrency($num, $curr) . ' in ' . $curr . PHP_EOL;
Previous Comments:
------------------------------------------------------------------------
[2013-01-02 08:35:24] fkrautwald at gmail dot com
I donât believe it is a bug. The problem is the example code. It errors when
you
copy it. There is some invisible invalid character between the space and the
dollar sign, I believe. Try to replace the space character and the dollar sign
in
the `$num` variable, typing it.
You can also check it with this code:
$fmt = new \NumberFormatter('de_DE', \NumberFormatter::CURRENCY);
$num = "1.234.567,89Â $";
print "We have ".$fmt->parseCurrency($num, $curr)." in $curr\n";
------------------------------------------------------------------------
[2012-10-23 12:41:26] mail at michael-weimann dot eu
Doesn't work in PHP 5.3.10
intl version 1.1.0
ICU version 4.8.1.1
ICU Data version 4.8.1
------------------------------------------------------------------------
[2012-05-05 09:15:37] franssen dot roland at gmail dot com
Still fails in PHP 5.4RC9...
version 1.1.0
ICU version 4.4.2
ICU Data version 4.4.2
------------------------------------------------------------------------
[2011-11-09 04:56:08] johnlinton at mailinator dot net
Seeing the same issue except I am using PHP 5.3.8 as a fcgi module under apache
2.2 on Windows 7.
------------------------------------------------------------------------
[2011-08-23 18:09:34] franssen dot roland at gmail dot com
Still fails in 5.3.8...
However it does seems to work when parsing in locale en[_US], e.g. $1 returns
float(1) ("USD"). Didn't spot any other locales that work (mostly tested
european locales; netherlands, germany, french)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=55290
--
Edit this bug report at https://bugs.php.net/bug.php?id=55290&edit=1