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

Re: Perl 5.20.0 Blockers, 2014-03-24

Thread Previous | Thread Next
From:
Craig A. Berry
Date:
March 25, 2014 03:08
Subject:
Re: Perl 5.20.0 Blockers, 2014-03-24
Message ID:
CA+vYcVyAqoO0gV-A2sjBROFbLk-6Xk=+kf7BXxeyZj_BBed8Ow@mail.gmail.com
On Mon, Mar 24, 2014 at 11:08 AM, Zefram <zefram@fysh.org> wrote:
> Ricardo Signes wrote:
>>3.  "Make perlbug Unicode-aware" broke perlbug on Win32
>>    https://rt.perl.org/Ticket/Display.html?id=121277
>
> I think there's a bug in the Unicode-awareness patch.  $input_encoding is
> set by
>
>         my $input_encoding = $::Have_get_locale_encoding ? encoding::_get_locale_encoding() : '';
>
> and then used as
>
>         open(F, "<:$input_encoding", $file)
>
> $input_encoding will get values such as "UTF-8" and "ANSI_X3.4-1968"
> which are not valid layer names.  It should instead be initialised as
>
>         my $input_encoding = $::Have_get_locale_encoding ?
>                 "encoding(@{[encoding::_get_locale_encoding()]})" : '';

Thanks for spotting this.  The code as-is worked fine in my testing
with the default encodings on Mac OS X, VMS, and Windows, but those
were all U.S. English environments so perhaps not representative.  I
don't actually understand why encoding names don't work as layer names
and thought I had seen something indicating they do.  Also, I'm not
sure whether _get_locale_encoding can ever return an empty string.  If
it can, I think Zefram's suggestion would be using an empty encoding
rather than an empty layer; the latter is documented to work but I'm
not sure about the former.

> As for the CRLF issue, perlbug should probably detect whether :crlf is
> a default layer and handle it appropriately.

Does the :crlf layer even work with Unicode?  Some people seem to
think it doesn't (e.g.,
<http://stackoverflow.com/questions/3320189/crlf-translation-with-unicode-in-perl>)
but I don't know enough to evaluate.  If it can be made to work so
that Unicode handling is not lost, I'm ok with supporting CRLF line
endings, but it's really a bug in Notepad and not in Perl.

> Something like
>
>         use PerlIO ();
>         my $crlf = (grep { $_ eq "crlf" } PerlIO::get_layers(STDOUT)) ?
>                 ":crlf" : "";
>         ...
>         open(REP, ">:raw $crlf", $filename)
>         ...
>         open(REP, "<:raw $crlf", $filename)
>
> (The opening for input occurs in four places.)
>
> -zefram

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