develooper Front page | perl.perl5.porters | Postings from March 2001

Re: [ID 20010225.003] inconsistencies in locale support

Thread Previous | Thread Next
March 2, 2001 18:29
Re: [ID 20010225.003] inconsistencies in locale support
Message ID:
On Fri, Mar 02, 2001 at 09:21:41AM -0600, Jarkko Hietaniemi wrote:
> If you can
> point out some of the spots where setlocale() acrobatics would be
> needed, I can take a look them.

Hmm, looks like I missed an essential point:  locale support is not
dependent on 'use locale' at all!  This seems to be intentional.
perl unconditionally calls setlocale() on startup, and never calls
it again (unless you use POSIX::setlocale() explictly).  So
POSIX::isalpha() respects $LANG by default, even if you never
mention the locale pragma.

It is only where (core) perl has a choice between calling a
locale-sensitive libc function, and doing things its own way (eg,
hard-coding character semantics), that the locale pragma currently
matters.  Since the string value of $! requires calling a
locale-sensitive function (strerror()), $! always respects locale.

perllocale is not at all clear on this; I expected that without "use
locale", the locale system would never be initialized.  However, the doc says what seems to be the intent:

    This pragma tells the compiler to enable (or disable) the use of
    POSIX locales for built-in operations

Should we take that as the law of the land?  In that case, the only
bug I know about is $! .  (Possibly also $^E .)  setlocale()
acrobatics are the obvious solution.  I will poke around for more if
the above rule is agreed upon.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About