money icon indicating copy to clipboard operation
money copied to clipboard

Unable to parse SDG.

Open birdy247 opened this issue 3 years ago • 5 comments

When trying to parse S$10.00 We receive this error

Upon investigation it appears to fail on line 49 on the IntlMoneyParser.php because the PHP NumberFormatter returns false i.e. its unable to parse it to a decimal.

PHP 7.2

Any ideas?

birdy247 avatar Jul 22 '22 13:07 birdy247

Can you provide example code that reproduces this? Also, which version are you using?

I'd consider upgrading PHP, just btw, at least to the latest version 7 or maybe even 8.

UlrichEckhardt avatar Jul 22 '22 15:07 UlrichEckhardt

`

    $currencies = new ISOCurrencies();

    $numberFormatter = new \NumberFormatter('en_GB', \NumberFormatter::CURRENCY);
    $moneyParser = new IntlMoneyParser($numberFormatter, $currencies);
    $money = $moneyParser->parse($value);

    return $money->getAmount();

`

version: 3.2.1

birdy247 avatar Jul 22 '22 15:07 birdy247

@UlrichEckhardt Just checking you saw this. Any ideas (other than the PHP version)? Thanks in advance

birdy247 avatar Jul 25 '22 11:07 birdy247

Oh, yes, saw it but slipped underneath the radar again... Just for completeness, can you set the value of $value in your code snippet?

UlrichEckhardt avatar Jul 25 '22 18:07 UlrichEckhardt

Also, the NumberFormatter, how would that format the numeric value you're expecting as a result from parsing? The idea is to turn the process around, just to rule out that the input does not have the format expected by the parser.

UlrichEckhardt avatar Jul 25 '22 18:07 UlrichEckhardt

PHP 7.2, no support anymore.

frederikbosch avatar Dec 15 '22 18:12 frederikbosch