4 require Config; import Config;
5 if ($Config{'extensions'} !~ /\Encode\b/) {
6 print "1..0 # Skip: Encode was not built\n";
11 use Encode qw(from_to);
12 use charnames qw(greek);
13 my @encodings = grep(/iso8859/,Encode::encodings());
15 plan test => 13+$n*@encodings;
16 my $str = join('',map(chr($_),0x20..0x7E));
18 ok(length($str),from_to($cpy,'iso8859-1','Unicode'),"Length Wrong");
19 ok($cpy,$str,"ASCII mangled by translating from iso8859-1 to Unicode");
21 ok(from_to($cpy,'Unicode','iso8859-1'),length($str),"Length wrong");
22 ok($cpy,$str,"ASCII mangled by translating from Unicode to iso8859-1");
24 $str = join('',map(chr($_),0xa0..0xff));
26 ok(length($str),from_to($cpy,'iso8859-1','Unicode'),"Length Wrong");
28 my $sym = Encode->getEncoding('symbol');
29 my $uni = $sym->toUnicode('a');
30 ok("\N{alpha}",substr($uni,0,1),"alpha does not map so symbol 'a'");
31 $str = $sym->fromUnicode("\N{Beta}");
32 ok("B",substr($str,0,1),"Symbol 'B' does not map to Beta");
34 foreach my $enc (qw(symbol dingbats ascii),@encodings)
36 my $tab = Encode->getEncoding($enc);
37 ok(1,defined($tab),"Could not load $enc");
38 $str = join('',map(chr($_),0x20..0x7E));
39 $uni = $tab->toUnicode($str);
40 $cpy = $tab->fromUnicode($uni);
41 ok($cpy,$str,"$enc mangled translating to Unicode and back");