Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69473 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12631 invoked from network); 3 Oct 2013 07:43:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Oct 2013 07:43:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@marc-bennewitz.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@marc-bennewitz.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain marc-bennewitz.de from 80.237.132.171 cause and error) X-PHP-List-Original-Sender: php@marc-bennewitz.de X-Host-Fingerprint: 80.237.132.171 wp164.webpack.hosteurope.de Received: from [80.237.132.171] ([80.237.132.171:51636] helo=wp164.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/90-09098-B302D425 for ; Thu, 03 Oct 2013 03:43:56 -0400 Received: from dslb-088-072-012-194.pools.arcor-ip.net ([88.72.12.194] helo=[192.168.178.27]); authenticated by wp164.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) id 1VRdZh-0006b3-7n; Thu, 03 Oct 2013 09:43:53 +0200 Message-ID: <524D2038.5050006@marc-bennewitz.de> Date: Thu, 03 Oct 2013 09:43:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: internals@lists.php.net References: <524C5E81.6030907@oracle.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-bounce-key: webpack.hosteurope.de;php@marc-bennewitz.de;1380786236;1c3e4b54; Subject: Re: [PHP-DEV] Locale-independent double-to-string cast From: php@marc-bennewitz.de (Marc Bennewitz) Am 02.10.2013 20:38, schrieb Adam Harvey: > On 2 October 2013 10:57, Christopher Jones 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