nor toggling.
The C<io> options mean that any subsequent open() (or similar I/O
-operations) will have the C<:utf8> PerlIO layer implicitly applied
-to them, in other words, UTF-8 is expected from any input stream,
-and UTF-8 is produced to any output stream. This is just the default,
-with explicit layers in open() and with binmode() one can manipulate
-streams as usual.
+operations) in the current file scope will have the C<:utf8> PerlIO layer
+implicitly applied to them, in other words, UTF-8 is expected from any
+input stream, and UTF-8 is produced to any output stream. This is just
+the default, with explicit layers in open() and with binmode() one can
+manipulate streams as usual.
C<-C> on its own (not followed by any number or option list), or the
empty string C<""> for the C<PERL_UNICODE> environment variable, has the
BEGIN { require "./test.pl"; }
-plan(tests => 11);
+plan(tests => 13);
my $r;
my $tmpfile = tempfile();
+my $scriptfile = tempfile();
my $b = pack("C*", unpack("U0C*", pack("U",256)));
stderr => 1 );
like( $r, qr/^256(?:\r?\n)?$/s, '-Ci: auto-UTF-8 open for input' );
+open(S, ">$scriptfile") or die("open $scriptfile: $!");
+print S "open(F, q(<$tmpfile)); print ord(<F>); close F";
+close S;
+
+$r = runperl( switches => [ '-Ci', '-w' ],
+ progfile => $scriptfile,
+ stderr => 1 );
+like( $r, qr/^256(?:\r?\n)?$/s, '-Ci: auto-UTF-8 open for input affects the current file' );
+
+$r = runperl( switches => [ '-Ci', '-w' ],
+ prog => "do q($scriptfile)",
+ stderr => 1 );
+unlike( $r, qr/^256(?:\r?\n)?$/s, '-Ci: auto-UTF-8 open for input has file scope' );
+
$r = runperl( switches => [ '-CA', '-w' ],
prog => 'print ord shift',
stderr => 1,