| 1 | #!./perl |
| 2 | |
| 3 | BEGIN { |
| 4 | unless ($] >= 5.008 and find PerlIO::Layer 'perlio') { |
| 5 | print "1..0 # Skip: not perlio\n"; |
| 6 | exit 0; |
| 7 | } |
| 8 | require($ENV{PERL_CORE} ? "../../t/test.pl" : "../t/test.pl"); |
| 9 | } |
| 10 | |
| 11 | use utf8; |
| 12 | |
| 13 | skip_all("EBCDIC platform; testing not core") |
| 14 | if $::IS_EBCDIC && ! $ENV{PERL_CORE}; |
| 15 | |
| 16 | plan(tests => 2); |
| 17 | |
| 18 | my $bytes = |
| 19 | "\xce\x9c\xe1\xbd\xb7\xce\xb1\x20\xcf\x80\xe1\xbd\xb1\xcf\x80\xce". |
| 20 | "\xb9\xce\xb1\x2c\x20\xce\xbc\xe1\xbd\xb0\x20\xcf\x80\xce\xbf\xce". |
| 21 | "\xb9\xe1\xbd\xb0\x20\xcf\x80\xe1\xbd\xb1\xcf\x80\xce\xb9\xce\xb1". |
| 22 | "\xcd\xbe\x0a"; |
| 23 | |
| 24 | if ($::IS_EBCDIC) { |
| 25 | require($ENV{PERL_CORE} ? "../../t/charset_tools.pl" : "../t/charset_tools.pl"); |
| 26 | $bytes = byte_utf8a_to_utf8n($bytes) |
| 27 | } |
| 28 | |
| 29 | open my $fh, ">:raw", 'io_utf8argv'; |
| 30 | print $fh $bytes; |
| 31 | close $fh or die "close: $!"; |
| 32 | |
| 33 | |
| 34 | use open ":std", ":utf8"; |
| 35 | |
| 36 | use IO::Handle; |
| 37 | |
| 38 | @ARGV = ('io_utf8argv') x 2; |
| 39 | is *ARGV->getline, "Μία πάπια, μὰ ποιὰ πάπια;\n", |
| 40 | 'getline respects open pragma when magically opening ARGV'; |
| 41 | |
| 42 | is join('',*ARGV->getlines), "Μία πάπια, μὰ ποιὰ πάπια;\n", |
| 43 | 'getlines respects open pragma when magically opening ARGV'; |
| 44 | |
| 45 | END { |
| 46 | 1 while unlink "io_utf8argv"; |
| 47 | } |