ID: 31963
Updated by: [EMAIL PROTECTED]
Reported By: wulff at fyens dot dk
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 4.3.10
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2005-02-14 09:42:15] wulff at fyens dot dk
Description:
------------
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;
current_locale=localeconv();
decimal_point=(*(*current_locale).decimal_point);
#endif
Reproduce code:
---------------
<?php
setLocale(LC_ALL,"de_DE");
echo ("2,2"*2)."\n";
?>
Expected result:
----------------
The result one would expect if PHP respected locale:
4,4
Actual result:
--------------
What you get is:
4
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31963&edit=1