1#!./perl
2
3BEGIN {
4    unless (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
11use utf8;
12
13skip_all("EBCDIC platform; testing not core")
14                                           if $::IS_EBCDIC && ! $ENV{PERL_CORE};
15
16plan(tests => 2);
17
18my $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
24if ($::IS_EBCDIC) {
25    require($ENV{PERL_CORE} ? "../../t/charset_tools.pl" : "./t/charset_tools.pl");
26    $bytes = byte_utf8a_to_utf8n($bytes)
27}
28
29open my $fh, ">:raw", 'io_utf8argv';
30print $fh $bytes;
31close $fh or die "close: $!";
32
33
34use open ":std", ":utf8";
35
36use IO::Handle;
37
38@ARGV = ('io_utf8argv') x 2;
39is *ARGV->getline, "Μία πάπια, μὰ ποιὰ πάπια;\n",
40  'getline respects open pragma when magically opening ARGV';
41
42is join('',*ARGV->getlines), "Μία πάπια, μὰ ποιὰ πάπια;\n",
43  'getlines respects open pragma when magically opening ARGV';
44
45END {
46  1 while unlink "io_utf8argv";
47}
48