php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40360 current locale affects how json_encode encodes floats
Submitted: 2007-02-05 02:09 UTC Modified: 2007-02-05 03:16 UTC
From: ftl_ at freemail dot hu Assigned:
Status: Closed Package: Variables related
PHP Version: 5.2.0 OS: Gentoo Linux
Private report: No CVE-ID: None
 [2007-02-05 02:09 UTC] ftl_ at freemail dot hu
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"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-05 03:16 UTC] ftl_ at freemail dot hu
fixed in PHP 5.2.1RC5-dev (cli) (built: Feb  5 2007 00:22:58)
(sorry for this thoughtless bugreport.)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC