From:             wulff at fyens dot dk
Operating system: Linux
PHP version:      4.3.10
PHP Bug Type:     Scripting Engine problem
Bug description:  zend_strtod.c does not respect locale.

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 bug report at http://bugs.php.net/?id=31963&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31963&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31963&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31963&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31963&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31963&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31963&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31963&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31963&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31963&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31963&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=31963&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=31963&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31963&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31963&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31963&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31963&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31963&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31963&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31963&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31963&r=mysqlcfg

Reply via email to