perl-unicode

Re: My favorite bug to fix for 5.8.0

2002-03-10 09:43:35
On Sun, Mar 10, 2002 at 02:07:15PM +0000, Nick Ing-Simmons wrote:
Jarkko Hietaniemi <jhi(_at_)iki(_dot_)fi> writes:

I started doing this at one point by making Perl to understand the
langinfo(CODESET) thingy (I18N::Langinfo), but at some point I was
somewhat disheartened by the sucky support of langinfo() across the
platforms and walked away in disgust.

Can we Configure test for working langinfo(CODESET), and if good enough
make :locale the default - which I think is what Larry's wish means?

Possibly.  The only drawback I see is that then the Perl I/O behaviour
of the same release of Perl is different across platforms.
Essentially, it would make the locale pragma the default on certain
areas: things work differently depending on what locales are available,
and which locales the user is using.  Not that it wouldn't be the
right thing to do; it's just something that we haven't done so far.
Given that the default locale setup is screwy (e.g. in Mac OS X)
in many places, I don't want to make that decision.

Another thing is that I notice I got the current logic of
"use open ':locale'" wrong.  Let's try again:
(1) if langinfo(CODESET) returns something, it is used as the
    default encoding for opens
(2) if langinfo didn't work and we are under the locale pragma,
    the $ENV{LC_ALL} and LANG (in that order) are matched for any
    encoding (stuff after a "."), and if any found, that is being used
(3) if (1) and (2) didn't work, the LC_ALL and LANG are matched again
    for /\butf-?8/i, and if found, :utf8 is used for the default encoding
    for opens

Now while I'm at it, I might record the above logic to the pod of open.pm...

However, one can even currently (in 5.7.3) say use open ':locale' and
if your langinfo() returns something matching /utf-?8/i you will get
automagic utf8-fication on your I/O (Not on your STDIN and OUT,
though).  At least, that was the theory and plan.

What is the issue with doing it for STDIN..STDERR ?

No good reason not to, I guess.  So should "use open ':locale'"
automatically binmode the IN..ERR to the whatever locale we can find?

One should be able to binmode them when we have established what 
the layer(s) should be?

-- 
Nick Ing-Simmons
http://www.ni-s.u-net.com/

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen