Edit report at http://bugs.php.net/bug.php?id=54538&edit=1

 ID:                 54538
 User updated by:    davidkarlin at gmail dot com
 Reported by:        davidkarlin at gmail dot com
 Summary:            setlocale() interferes with NumberFormatter class
 Status:             Open
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   OS X
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

Sorry - I typed the wrong lines in the expected and actual results.
Should be 

"123.456,789" in both cases. But you get the idea...


Previous Comments:
------------------------------------------------------------------------
[2011-04-15 13:32:41] davidkarlin at gmail dot com

Description:
------------
---

>From manual page: http://www.php.net/class.numberformatter

---

When I have my locale set to 'en' with setlocale(), the NumberFormatter
class 

works just fine.



If I set the locale to, for example, 'fr_FR', the NumberFormatter class
fails, 

giving a 'NaN' result. This is irrespective of the fact that the
setlocale() 

function has clearly worked, as evidenced by gettext() working just
fine.



I can't see any reason why the setlocale function should have anything
to do with 

the operation of NumberFormatter: this isn't documented, and I'm
explicitly 

passing the locale I want to use in the parameter.



Using 5.3.5 (the most recent available through MacPorts)

Test script:
---------------
setlocale(LC_ALL, 'en');

$nf = new NumberFormatter('de_DE',NumberFormatter::DECIMAL);

print $nf->format(123456.789);  // Outputs the correct answer 123.456,789


print "<br/>\n";

setlocale(LC_ALL, 'fr_FR');     

$nf = new NumberFormatter('de_DE',NumberFormatter::DECIMAL);

print $nf->format(123456.789); // Outputs NaN

Expected result:
----------------
123456.789<br/>

123456.789

Actual result:
--------------
123456.789<br/>

NaN


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



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54538&edit=1

Reply via email to