develooper Front page | perl.perl5.porters | Postings from May 2013

Re: [perl #63402] use open :locale doesn't work in Windows

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
May 28, 2013 08:43
Subject:
Re: [perl #63402] use open :locale doesn't work in Windows
Message ID:
20130528084250.GJ3729@plum.flirble.org
On Mon, May 27, 2013 at 09:38:15PM -0400, Eric Brine wrote:
> On Sun, May 26, 2013 at 11:59 PM, Eric Brine <ikegami@adaelis.com> wrote:
> 
> > On Sun, May 26, 2013 at 1:40 PM, bulk88 via RT <perlbug-followup@perl.org>wrote:
> >
> >> No change in behavior the reporter observed on 5.19.0. I can't comment
> >> whether there is a bug here or not.
> >>
> >
> > Well, I don't think having the following lead every portable script is a
> > proper expectation of Perl programmers:
> >
> >     my $encoding;
> >     BEGIN {
> >        if ($^O eq 'MSWin32') {
> >           require Win32;
> >           my $cp = Win32::GetConsoleCP();
> >           $encoding = ":encoding(cp$cp)";
> >        } else {
> >           $encoding = ':locale';
> >        }
> >     }
> >
> >     use open ':std', $encoding;
> >
> > The solution may not be to change :locale.
> >
> 
> In fact, the solution can be implemented in a module. Given this and given
> the fact that it's very unlikely that this ticket will motivate anyone to
> work on this problem, so you can close this ticket if you want.

However, it's not documented in open.pm's Pod that :locale only works on
*nix. So if we decide that we're not going to change the code, we should at
least document the current behaviour/limitations.

I guessing that it's sort of *implied* by this:

    The logic of C<:locale> is described in full in L<encoding>,
    but in short it is first trying nl_langinfo(CODESET) and then
    guessing from the LC_ALL and LANG locale environment variables.


but only by reversing out from this bug report and inferring that none of
those approaches work on Win32.

Also, given that :locale uses encoding, and we've said we're going to remove
encoding.pm, doesn't that mean that :locale itself needs deprecating? Or, at
least, rethinking?

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About