-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Invalid default return value for setlocale() #5562
Copy link
Copy link
Closed
Description
Trying to fetch the default locale returns the empty string, when in fact it should be "C".
Since setting the locale to the empty string changes it to the default of the system (which is not C usually), this makes it impossible to save the current locale, do some stuff, and restore it correctly afterwards.
var_dump(setlocale(LC_NUMERIC, 0));
echo sprintf('%s', 4.3), "\n";
var_dump(setlocale(LC_NUMERIC, ''));
echo sprintf('%s', 4.3), "\n";echoes:
string(0) ""
4.3
string(0) ""
4,3
Not the comma vs dot in the float to string conversion.
The same script on PHP echoes:
string(1) "C"
4.3
string(11) "fr_FR.UTF-8"
4,3
which is much better.
Reactions are currently unavailable