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";
13 unless( eval { require Encode } ) {
14 print "1..0 # Skip: No Encode\n";
18 import Encode qw(:fallback_all);
21 # $PerlIO::encoding = 0; # WARN_ON_ERR|PERLQQ;
23 my $file = "fallback$$.txt";
27 local $SIG{__WARN__} = sub { $message = $_[0] };
28 $PerlIO::encoding::fallback = Encode::PERLQQ;
29 ok(open(my $fh,">encoding(iso-8859-1)",$file),"opened iso-8859-1 file");
31 print $fh $str,"0.02\n";
33 like($message, qr/does not map to iso-8859-1/o, "FB_WARN message");
36 open($fh,$file) || die "File cannot be re-opened";
38 is($line,"\\x{20ac}0.02\n","perlqq escapes");
41 $PerlIO::encoding::fallback = Encode::HTMLCREF;
43 ok(open(my $fh,">encoding(iso-8859-1)",$file),"opened iso-8859-1 file");
45 print $fh $str,"0.02\n";
48 open($fh,$file) || die "File cannot be re-opened";
50 is($line,"€0.02\n","HTML escapes");
55 open($fh,">$file") || die "File cannot be re-opened";
57 print $fh "\xA30.02\n";
61 ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII");
63 printf "# %x\n",ord($line);
64 is($line,"\\xA30.02\n","Escaped non-mapped char");
67 $PerlIO::encoding::fallback = Encode::WARN_ON_ERROR;
69 ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII");
71 printf "# %x\n",ord($line);
72 is($line,"\x{FFFD}0.02\n","Unicode replacement char");
76 1 while unlink($file);