#40360 [NEW]: current locale affects how json_encode encodes floats
| From: | ftl_ at freemail dot hu | Date: | Mon, 05 Feb 2007 02:09:29 +0000 |
| Subject: | #40360 [NEW]: current locale affects how json_encode encodes floats | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-108399@lists.php.net to get a copy of this message | ||
From: ftl_ at freemail dot hu
Operating system: Gentoo Linux
PHP version: 5.2.0
PHP Bug Type: Variables related
Bug description: current locale affects how json_encode encodes floats
Description:
------------
json_encode is using the decimal separator of the current locale instead
of using "."
(similar to http://bugs.php.net/bug.php?id=40235)
Reproduce code:
---------------
<?php
var_dump(json_encode(1.2));
setlocale(LC_NUMERIC, 'hu_HU');
var_dump(json_encode(1.2));
?>
Expected result:
----------------
string(3) "1.2"
string(3) "1.2"
Actual result:
--------------
string(3) "1.2"
string(3) "1,2"
--
Edit bug report at http://bugs.php.net/?id=40360&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40360&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40360&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40360&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40360&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40360&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40360&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40360&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40360&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40360&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40360&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40360&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40360&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40360&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40360&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40360&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40360&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40360&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40360&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40360&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40360&r=mysqlcfg