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

Re: Perl 5.20.0 Blockers, 2014-03-24

Thread Previous | Thread Next
Craig A. Berry
March 25, 2014 03:08
Re: Perl 5.20.0 Blockers, 2014-03-24
Message ID:
On Mon, Mar 24, 2014 at 11:08 AM, Zefram <> wrote:
> Ricardo Signes wrote:
>>3.  "Make perlbug Unicode-aware" broke perlbug on Win32
> 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.,
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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About