develooper Front page | perl.perl5.porters | Postings from February 2012

Re: [perl #5907] inconsistencies in locale support

Thread Previous | Thread Next
Karl Williamson
February 1, 2012 09:39
Re: [perl #5907] inconsistencies in locale support
Message ID:
On 01/30/2012 07:34 PM, James E Keenan via RT wrote:
> On Fri Mar 02 10:29:21 2001, RT_System wrote:
>> 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.
>> Andrew
> There has been no movement on this ticket for nearly eleven years.
> Does anyone feel we are in need of the "setlocale acrobatics" discussed
> in this ticket?  If so, then we should probably outline those in a new
> RT.  If not, we should close the ticket.
> Thank you very much.
> Jim Keenan
> ---
> via perlbug:  queue: perl5 status: open

I wonder why we call setlocale unconditionally.  Why not call it upon 
the first encountered 'use locale'?  That would solve this problem and 
others I've heard about.

There are no comments as to why it's always called and I did not see 
anything in the commit messages

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