|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31963 zend_strtod.c does not respect locale.
Submitted: 2005-02-14 09:42 UTC Modified: 2005-02-14 10:11 UTC
From: wulff at fyens dot dk Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.10 OS: Linux
Private report: No CVE-ID: None
 [2005-02-14 09:42 UTC] wulff at fyens dot dk
The Zend engine does not respect the current locale when it converts from a string to a float.

Zend assumes that all numbers have a "." as a decimal seperator. This is not the case in many parts of the world.

Included in this bug is a bit of "non-portable" code that solves the problem. This may not be the most elegant solution but it illustrates what needs to be fixed. 

Here are my changes to Zend/zend_strtod.c at line 1249:

//      CONST char decimal_point = ',';

        char decimal_point = '.';
        #ifdef HAVE_LOCALE_H
        struct lconv* current_locale;

Reproduce code:
  echo ("2,2"*2)."\n";

Expected result:
The result one would expect if PHP respected locale:

Actual result:
What you get is:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-14 10:11 UTC]
THe reason why we introduced this zend_strtod.c was exactly because of this reason. This is not a bug, but expected and wanted behavior.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Aug 14 12:05:49 2022 UTC