Re: Locale-independent double-to-string cast
| From: | Marc Bennewitz | Date: | Thu, 03 Oct 2013 07:43:52 +0000 |
| Subject: | Re: Locale-independent double-to-string cast | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-69473@lists.php.net to get a copy of this message | ||
Am 02.10.2013 20:38, schrieb Adam Harvey:
> On 2 October 2013 10:57, Christopher Jones <christopher.jones@oracle.com> wrote:
>> On 10/02/2013 10:26 AM, Nikita Popov wrote:
>>> I'd like to change our double-to-string casting behavior to be
>>> locale-independent and would appreciate some opinions as to whether you
>>> consider this feasible.
>>
>> I'd like to see float/double casts recognize the locale's decimal
>> separator.
>
> That's an interesting idea, and arguably one that's more in line with
> what PHP has been doing.
>
> I'd be really interested to hear from people in countries where the
> decimal separator is a comma, since I don't have any experience with
> this myself as an Anglophone — do you run PHP in your native locale,
> and if so, would it be better to always have dots, as Nikita suggests,
> or support parsing numbers with commas? (Or some combination therein.)
+1
This is an issue I often ran into.
In my opinion on type casting a value from/to string it should use the
standard computer format and not a localized one. To format to a
localized format we have a function named "number_format" and since PHP
5.3 the class "NumberFormatter".
Additionally "setlocale" is a process operation that makes issues on
multi threaded envs. So temporary reset the locale isn't same, too.
My little two cent from germany
Marc