6 push @INC, "::lib:$MacPerl::Architecture:" if $^O eq 'MacOS';
7 require "../t/test.pl";
8 skip_all("No perlio") unless (find PerlIO::Layer 'perlio');
10 print "1..0 # Skip: EBCDIC\n";
15 use Encode qw(:fallback_all);
17 # $PerlIO::encoding = 0; # WARN_ON_ERR|PERLQQ;
19 my $file = "fallback$$.txt";
23 local $SIG{__WARN__} = sub { $message = $_[0] };
24 $PerlIO::encoding::fallback = Encode::PERLQQ;
25 ok(open(my $fh,">encoding(iso-8859-1)",$file),"opened iso-8859-1 file");
27 print $fh $str,"0.02\n";
29 like($message, qr/does not map to iso-8859-1/o, "FB_WARN message");
32 open($fh,$file) || die "File cannot be re-opened";
34 is($line,"\\x{20ac}0.02\n","perlqq escapes");
37 $PerlIO::encoding::fallback = Encode::HTMLCREF;
39 ok(open(my $fh,">encoding(iso-8859-1)",$file),"opened iso-8859-1 file");
41 print $fh $str,"0.02\n";
44 open($fh,$file) || die "File cannot be re-opened";
46 is($line,"€0.02\n","HTML escapes");
51 open($fh,">$file") || die "File cannot be re-opened";
53 print $fh "\xA30.02\n";
57 ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII");
59 printf "# %x\n",ord($line);
60 is($line,"\\xA30.02\n","Escaped non-mapped char");
63 $PerlIO::encoding::fallback = Encode::WARN_ON_ERROR;
65 ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII");
67 printf "# %x\n",ord($line);
68 is($line,"\x{FFFD}0.02\n","Unicode replacement char");
72 1 while unlink($file);