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 <http://www.ailis.de/~k/> (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to