Bug #54538 [NEW]: setlocale() interferes with NumberFormatter class
| From: | davidkarlin at gmail dot com | Date: | Fri, 15 Apr 2011 11:32:42 +0000 |
| Subject: | Bug #54538 [NEW]: setlocale() interferes with NumberFormatter class | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-160183@lists.php.net to get a copy of this message | ||
From:
Operating system: OS X
PHP version: 5.3.6
Package: Unknown/Other Function
Bug Type: Bug
Bug description:setlocale() interferes with NumberFormatter class
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 bug report at http://bugs.php.net/bug.php?id=54538&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54538&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54538&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54538&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54538&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54538&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54538&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54538&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54538&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54538&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54538&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54538&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54538&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54538&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54538&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54538&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54538&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54538&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54538&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54538&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54538&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54538&r=mysqlcfg