6 require "../t/test.pl";
7 skip_all("No perlio") unless (find PerlIO::Layer 'perlio');
9 print "1..0 # Skip: EBCDIC\n";
14 use Encode qw(:fallback_all);
16 # $PerlIO::encoding = 0; # WARN_ON_ERR|PERLQQ;
18 my $file = "fallback$$.txt";
22 local $SIG{__WARN__} = sub { $message = $_[0] };
23 $PerlIO::encoding::fallback = Encode::PERLQQ;
24 ok(open(my $fh,">encoding(iso-8859-1)",$file),"opened iso-8859-1 file");
26 print $fh $str,"0.02\n";
28 like($message, qr/does not map to iso-8859-1/o, "FB_WARN message");
31 open($fh,$file) || die "File cannot be re-opened";
33 is($line,"\\x{20ac}0.02\n","perlqq escapes");
36 $PerlIO::encoding::fallback = Encode::HTMLCREF;
38 ok(open(my $fh,">encoding(iso-8859-1)",$file),"opened iso-8859-1 file");
40 print $fh $str,"0.02\n";
43 open($fh,$file) || die "File cannot be re-opened";
45 is($line,"€0.02\n","HTML escapes");
48 open($fh,">$file") || die "File cannot be re-opened";
52 ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII");
54 printf "# %x\n",ord($line);
55 is($line,"\\xA30.02\n","Escaped non-mapped char");
58 $PerlIO::encoding::fallback = Encode::WARN_ON_ERROR;
60 ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII");
62 printf "# %x\n",ord($line);
63 is($line,"\x{FFFD}0.02\n","Unicode replacement char");
67 1 while unlink($file);