Bug #55290 [Opn->Csd]: \NumberFormatter::parseCurrency() fails

From: Date: Mon, 01 Feb 2021 15:40:09 +0000
Subject: Bug #55290 [Opn->Csd]: \NumberFormatter::parseCurrency() fails
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231869@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55290&edit=1

 ID:                 55290
 Updated by:         cmb@php.net
 Reported by:        franssen dot roland at gmail dot com
 Summary:            \NumberFormatter::parseCurrency() fails
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            I18N and L10N related
 Operating System:   Linux
 PHP Version:        5.3.6 - 5.3.8
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

This issue has been fixed long ago[1].

[1] <http://git.php.net/?p=doc/en.git;a=commit;h=f7af074111bf3c6fe840d5cbb4a76e3909c15d25>


Previous Comments:
------------------------------------------------------------------------
[2014-10-04 22:21:33] hannes dot forsgard at gmail dot com

Example

<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::CURRENCY );
$num = "1.234.567,89 $";
echo "We have ".$fmt->parseCurrency($num, $curr)." in $curr\n";
?>

rewritten as

<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::CURRENCY );
$num = "1.234.567,89\xc2\xa0$";
echo "We have ".$fmt->parseCurrency($num, $curr)." in $curr\n";
?>

works for me (php 5.5.16 on Ubuntu 12.04).

See http://stackoverflow.com/a/16509321

------------------------------------------------------------------------
[2013-01-03 01:46:39] fkrautwald at gmail dot com

That is odd that the example code had a hidden character which created an error, 
and removing it fixed the example on PHP 5.4.10 on Windows 7.

I am aware that this is filed as a bug under Linux, but what a remarkable 
coincidence.

------------------------------------------------------------------------
[2013-01-02 10:26:56] franssen dot roland at gmail dot com

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;

------------------------------------------------------------------------
[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

------------------------------------------------------------------------


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


Thread (11 messages)

« previous php.bugs (#231869) next »