From: oswald at jaskolla dot net
Operating system: Windows XP, Linux
PHP version: 5.2.6
PHP Bug Type: Strings related
Bug description: mismatch between sscanf and localeconv
Description:
------------
sscanf() seems not to be locale-aware when interpreting '%f', even though
the documentation says it is. localeconv() says that after my call to
setlocale(), the comma is interpreted as decimal separator. Still
everything after the comma is omitted.
Tested environments:
Windows XP, PHP 5.2.5, Apache 2.2.8 (mpm_winnt)
Linux 2.6.9, PHP 5.2.6RC1, Apache 2.2.8 (prefork)
Reproduce code:
---------------
setlocale(LC_ALL, array('de_DE.utf-8', 'german'));
$value = sscanf('3,14159265', '%f');
echo '<div>parsed: π ≈', $value[0], '</div>';
echo '<div>formatted: π ≈'; printf('%f', 3.14159265); echo
'</div>';
Expected result:
----------------
parsed: π ≈3.14159265
formatted: π ≈3,14159265
Actual result:
--------------
parsed: π ≈3
formatted: π ≈3,14159265
--
Edit bug report at http://bugs.php.net/?id=46267&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46267&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46267&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46267&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46267&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=46267&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46267&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46267&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46267&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46267&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46267&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46267&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46267&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46267&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46267&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46267&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46267&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46267&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46267&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46267&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46267&r=mysqlcfg