Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13632 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38324 invoked by uid 1010); 30 Oct 2004 12:46:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 35368 invoked from network); 30 Oct 2004 12:46:10 -0000 Received: from unknown (HELO malcolm.ailis.de) (217.115.149.166) by pb1.pair.com with SMTP; 30 Oct 2004 12:46:10 -0000 Received: (qmail 29959 invoked by uid 64014); 30 Oct 2004 12:47:29 -0000 Received: from pd95fa6d2.dip.t-dialin.net (HELO ?192.168.36.101?) (k@217.95.166.210) by malcolm.ailis.de with SMTP; 30 Oct 2004 12:47:27 -0000 Message-ID: <41838C66.4040604@ailis.de> Date: Sat, 30 Oct 2004 14:43:18 +0200 User-Agent: Mozilla Thunderbird 0.8 (X11/20040926) X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS 0.3.12 Subject: localeconv not working From: k-php-dev@ailis.de (Klaus Reimer) Hello, I just notices that localeconv is not working properly (at least in PHP 5.0.2 and 4.3.9), it does not return the correct thousands_sep and decimal_point (See my mail at php-general). Now I took a quick look in the source code and I found this in ext/standard/string.c (function setlocale): if (cat == LC_NUMERIC || cat == LC_ALL) { struct lconv lc; localeconv_r(&lc); EG(float_separator)[0] = (lc.decimal_point)[0]; if ((lc.decimal_point)[0] != '.') { /* set locale back to C */ setlocale(LC_NUMERIC, "C"); } } I think this explains the misbehaviour. If I do a "setlocale(LC_ALL, 'de_DE')" then the PHP function resets LC_NUMERIC to "C". So what chance have I to get the LC_NUMERIC configuration of a specific locale now? Well, I think there was a good reason to reset LC_NUMERIC to C but this breaks localeconv(). I want to read the LC_NUMERIC configuration of the selected locale to use these informations with the number_format() function but I can't do it because of the above code. Is there a workaround? If not, then I suggest one (or both) of the following improvements: 1. setlocale remembers the real LC_NUMERIC setting before reseting it to C and localeconv sets this remembered locale before calling the localeconv_r() function. After the data has been retrieved, it resets LC_NUMERIC to C. in that way localeconv() behaves correctly and PHP still sticks to the default LC_NUMERIC setting. 2. You give localeconv optional parameters (same as setlocale) so it can be used to retrieve the locale configuration of a specific locale WITHOUT changing the global locale at all. -- Bye, K (FidoNet: 2:240/2188.18) [A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391] (Finger k@ailis.de to get public key)