#38785 [Opn]: float to string cast is always subject to locale settings

From: Date: Tue, 12 Sep 2006 00:05:25 +0000
Subject: #38785 [Opn]: float to string cast is always subject to locale settings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-102018@lists.php.net to get a copy of this message
ID: 38785 User updated by: m dot kurzyna at crystalpoint dot pl Reported By: m dot kurzyna at crystalpoint dot pl Status: Open Bug Type: *Languages/Translation Operating System: Linux -PHP Version: 5.6.1 +PHP Version: 5.1.6 New Comment: Wrong version in prevous comment. Previous Comments: ------------------------------------------------------------------------ [2006-09-12 00:04:46] m dot kurzyna at crystalpoint dot pl This behaviour is more general - it applyes to any float to string conversion wether it's explicit or implicit. There are some bugreports on this already though all are bound to some concrete functions. ------------------------------------------------------------------------ [2006-09-11 23:35:49] m dot kurzyna at crystalpoint dot pl Description: ------------ Stripslashes seems to be locale specific. It changes decimal point character when used in enviroment with locales set. I'm not shure is this a feature or a bug but it's something unexpected as it's not mensioned in the manual as far as I know. And it's easy to criple database input with this. As a locale to observe this behaviour one can set probably enything that uses comma rather then dot for decimal point. Reproduce code: --------------- $float = 0.10; // $float is now float 0.10 setlocale(LC_ALL,'C'); $r = stripslashes($float); // $r is now string "0.10" setlocale(LC_ALL,'pl_PL'); $r = stripslashes($float); // $r is now string "0,10" Expected result: ---------------- No change in decimalpoint or explicit note in documentation. Actual result: -------------- Provided in code example - change of decimal point character. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38785&edit=1

« previous php.bugs (#102018) next »