Bug #77278 [Ver]: floatval(strval(value)) truncates if locale's decimal_point isn't a period
| From: | nikic@php.net | Date: | Mon, 10 Dec 2018 21:59:50 +0000 |
| Subject: | Bug #77278 [Ver]: floatval(strval(value)) truncates if locale's decimal_point isn't a period | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218384@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77278&edit=1
ID: 77278
Updated by: nikic@php.net
Reported by: spam2 at rhsoft dot net
Summary: floatval(strval(value)) truncates if locale's
decimal_point isn't a period
Status: Verified
Type: Bug
Package: Scripting Engine problem
PHP Version: Irrelevant
-Block user comment: No
+Block user comment: Yes
Private report: N
New Comment:
Please calm down.
Previous Comments:
------------------------------------------------------------------------
[2018-12-10 21:52:37] spam2 at rhsoft dot net
ok, you can partially repdoduce that behavior
echo (string)4/3, "\n";
setlocale(LC_ALL, 'en_US.UTF-8');
echo (string)4/3, "\n";
setlocale(LC_ALL, 'de_DE.UTF-8');
echo (string)4/3, "\n";
-------------------------------
BUT YOU CANN NOT GET THE CURRECT LOCALE WITH PHP
echo (string)4/3, "\n";
setlocale(LC_ALL, 'en_US.UTF-8');
echo setlocale(LC_ALL, NULL), "\n";
echo (string)4/3, "\n";
setlocale(LC_ALL, 'de_DE.UTF-8');
echo setlocale(LC_ALL, NULL), "\n";
echo (string)4/3, "\n";
[harry@srv-rhsoft:/downloads]$ php test.php
1.3333333333333
de_DE.UTF-8
1,3333333333333
de_DE.UTF-8
1,3333333333333
-------------------------------
why don't that shit mention 'en_US.UTF-8' which i would have liked to put at the
libtidy bugreport instead wasting all my time with assumptions?
there is anyways no sibgle pojnt of have TYPECASTS behave different - that's what format
functions are!
------------------------------------------------------------------------
[2018-12-10 21:45:13] spam2 at rhsoft dot net
nonsense! show me the PHP code where type casts after setlocale() change tehir meaning!
you can't even distinct what happens by use setlocale('whatever', NULL) before and
after the tidy call because i get always get de_DE.UTF-8 as result
------------------------------------------------------------------------
[2018-12-10 21:41:36] requinix@php.net
You can't blame PHP for Tidy's problem. If they change locale (already a dangerous
operation since it's not thread-safe) and then don't revert it to the previous setting
when they're done, that's their fault.
------------------------------------------------------------------------
[2018-12-10 21:33:13] spam2 at rhsoft dot net
working as intended?
a random linked library calls locale and the whole behavior of internal php typecast changes for
every follow-up code in a PHP application is intended? really?
------------------------------------------------------------------------
[2018-12-10 21:29:50] nikic@php.net
I think we should get rid of the locale-dependent float to string cast in PHP 8, but for now this is
working as "intended". We should definitely *not* make string to float cast
locale-sensitive as well, that would only make a bad situation worse.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=77278
--
Edit this bug report at https://bugs.php.net/bug.php?id=77278&edit=1