6 require "../t/test.pl";
7 skip_all("No perlio") unless (find PerlIO::Layer 'perlio');
10 use Encode qw(:fallback_all);
12 # $PerlIO::encoding = 0; # WARN_ON_ERR|PERLQQ;
14 my $file = "fallback$$.txt";
16 $PerlIO::encoding::fallback = Encode::PERLQQ;
18 ok(open(my $fh,">encoding(iso-8859-1)",$file),"opened iso-8859-1 file");
20 print $fh $str,"0.02\n";
23 open($fh,$file) || die "File cannot be re-opened";
25 is($line,"\\x{20ac}0.02\n","perlqq escapes");
28 $PerlIO::encoding::fallback = Encode::HTMLCREF;
30 ok(open(my $fh,">encoding(iso-8859-1)",$file),"opened iso-8859-1 file");
32 print $fh $str,"0.02\n";
35 open($fh,$file) || die "File cannot be re-opened";
37 is($line,"€0.02\n","HTML escapes");
40 open($fh,">$file") || die "File cannot be re-opened";
44 ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII");
46 printf "# %x\n",ord($line);
47 is($line,"\\xA30.02\n","Escaped non-mapped char");
50 $PerlIO::encoding::fallback = Encode::WARN_ON_ERROR;
52 ok(open($fh,"<encoding(US-ASCII)",$file),"Opened as ASCII");
54 printf "# %x\n",ord($line);
55 is($line,"\x{FFFD}0.02\n","Unicode replacement char");
59 1 while unlink($file);