Skip to content

Commit

Permalink
Merge fd0cd1b into d6b338e
Browse files Browse the repository at this point in the history
  • Loading branch information
Leont committed Apr 8, 2021
2 parents d6b338e + fd0cd1b commit f44bfdf
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions lib/open.pm
@@ -1,7 +1,7 @@
package open;
use warnings;

our $VERSION = '1.12';
our $VERSION = '1.13';

require 5.008001; # for PerlIO::get_layers()

Expand Down Expand Up @@ -120,20 +120,11 @@ sub import {
${^OPEN} = join("\0", $in, $out);
if ($std) {
if ($in) {
if ($in =~ /:utf8\b/) {
binmode(STDIN, ":utf8");
} elsif ($in =~ /(\w+\(.+\))/) {
binmode(STDIN, ":$1");
}
binmode STDIN, $in;
}
if ($out) {
if ($out =~ /:utf8\b/) {
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
} elsif ($out =~ /(\w+\(.+\))/) {
binmode(STDOUT, ":$1");
binmode(STDERR, ":$1");
}
binmode(STDOUT, $out);
binmode(STDERR, $out);
}
}
}
Expand Down Expand Up @@ -243,6 +234,10 @@ to this pragma in its own lexical scope.
{ use open ':std', IO => ':encoding(UTF-8)' }
Before Perl 5.34, C<:std> would only apply the first layer provided that is
either C<:utf8> or has a layer argument, e.g. C<:encoding(UTF-8)>. Since
Perl 5.34 it will apply the same layer stack it provides to C<${^OPEN}>.
=head1 IMPLEMENTATION DETAILS
There is a class method in C<PerlIO::Layer> C<find> which is
Expand Down

0 comments on commit f44bfdf

Please sign in to comment.