Re: [PHP4BETA] bug or feature ???

From: Date: Tue, 23 May 2000 00:02:45 +0000
Subject: Re: [PHP4BETA] bug or feature ???
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-15490@lists.php.net to get a copy of this message
On Tue, 23 May 2000, Zeev Suraski wrote: > At 23:58 22/05/2000 , Sascha Schumann wrote: > >On Sun, 21 May 2000, Andi Gutmans wrote: > > > We are using the C library strtod() in order to convert the number to a > > > decimal. I see that strtod() uses locale. > > > How should this be handled? Should we move to a US locale for the > > > conversion? (probably a bit slow). > >I think using the locale is a feature, not a bug. If people choose to use > >locales we should not try to force an arbitrary locale onto them. > Due to the fact that we have to write a scanner that analyzes the tokens, > and recognizes floating point numbers, we can't support locales. If you have the option of introducing an extra variable into the scanner code, then the POSIX-standard function localeconv() returns a structure that can be queried to find the decimal point character for the current locale: /* Structure giving information about numeric and monetary notation. */ struct lconv { /* Numeric (non-monetary) information. */ char *decimal_point; /* Decimal point character. */ char *thousands_sep; /* Thousands separator. */ .... }; Only a suggestion--I really don't know lex and yacc that well, so I'm not sure what it would take to make use of this information. Trying to drop something variable like this into the middle of a parser is probably bad juju in any case. The other option, of course, is to make sure to switch to the C locale before making the dangerous function calls, and to then restore the previous locale when finished. Steve Langasek postmodern programmer

« previous php.version4 (#15490) next »