php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57985 parseCurrency() is broken
Submitted: 2007-12-30 16:49 UTC Modified: 2013-02-18 00:35 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: sfox@php.net Assigned:
Status: No Feedback Package: intl (PECL)
PHP Version: 5_2 CVS-2007-12-30 OS: Windows XP
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-12-30 16:49 UTC] sfox@php.net
Description:
------------
To start with, this is CVS from over a week ago (PHP_5_3 and PECL) but I can see from the commit list that it hasn't been fixed in the interim. The bug tracking system doesn't allow me to tell you this much. The ICU version I built PHP against is 3.4 (from Edin's library collection). I haven't tried yet with 3.4.1 or up.

I've tried with and without the currency symbol; I've tried shifting the position to match the first digit rather than the currency symbol; I've tried different currencies. The straightforward parse() method works perfectly, but the currencyParse() method does not - at least on my box.

Reproduce code:
---------------
<?php

$nf = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
$pos = 13;
print $nf->parseCurrency("When parsing ".$nf->format(123)." this will return false, or at least a hidden error", $currency, $pos)."\n";
print $currency."\n";
print $pos."\n";
print intl_get_error_message();

?>

Expected result:
----------------
123
USD
20 // note: I'm guessing wildly here. Above 13 anyway.
U_ZERO_ERROR

Actual result:
--------------

13
Number parsing failed: U_PARSE_ERROR




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-02 17:58 UTC] stas at zend dot com
Works for me with ICU 3.6 - could you test with more recent ICU?
 [2008-01-02 20:10 UTC] steph dot fox at virgin dot net
Not easily - there's no support whatever for building ICU 3.6 or up with MSVC 6, so it needs spending time on. Best I can do right now would be 3.4.1...

Is there any way you can test with 3.4 on your system so we can at least know if it's an old ICU bug?
 [2008-01-02 20:13 UTC] stas at zend dot com
I suspect that your ICU prints format() result without currency sign. Could you check what $nf->format() produces - 123 or $123?
 [2008-01-02 20:43 UTC] steph dot fox at virgin dot net
Nope, it gives currency sign, decimal point + two decimal places... I put that in the test script because I'd tried all the variations manually before posting a bug report. If it works for you though it still seems most likely an old ICU bug, I'd just like to be certain.

$nf = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
print $nf->format(123);
//$123.00
 [2013-02-18 00:35 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 09:01:27 2024 UTC