10 $ON_EBCDIC = ord("A") == 193;
11 @ARGV and $ON_EBCDIC = $ARGV[0] eq 'EBCDIC';
12 $Encode::ON_EBCDIC = $ON_EBCDIC;
15 'ascii' => 'US-ascii',
16 'cyrillic' => 'iso-8859-5',
17 'arabic' => 'iso-8859-6',
18 'greek' => 'iso-8859-7',
19 'hebrew' => 'iso-8859-8',
20 'thai' => 'iso-8859-11',
21 'tis620' => 'iso-8859-11',
22 'WinLatin1' => 'cp1252',
23 'WinLatin2' => 'cp1250',
24 'WinCyrillic' => 'cp1251',
25 'WinGreek' => 'cp1253',
26 'WinTurkish' => 'cp1254',
27 'WinHebrew' => 'cp1255',
28 'WinArabic' => 'cp1256',
29 'WinBaltic' => 'cp1257',
30 'WinVietnamese' => 'cp1258',
31 'ja_JP.euc' => $ON_EBCDIC ? '' : 'euc-jp',
32 'x-euc-jp' => $ON_EBCDIC ? '' : 'euc-jp',
33 'zh_CN.euc' => $ON_EBCDIC ? '' : 'euc-cn',
34 'x-euc-cn' => $ON_EBCDIC ? '' : 'euc-cn',
35 'ko_KR.euc' => $ON_EBCDIC ? '' : 'euc-kr',
36 'x-euc-kr' => $ON_EBCDIC ? '' : 'euc-kr',
37 'ujis' => $ON_EBCDIC ? '' : 'euc-jp',
38 'Shift_JIS' => $ON_EBCDIC ? '' : 'shiftjis',
39 'x-sjis' => $ON_EBCDIC ? '' : 'shiftjis',
40 'jis' => $ON_EBCDIC ? '' : '7bit-jis',
41 'big-5' => $ON_EBCDIC ? '' : 'big5',
42 'zh_TW.Big5' => $ON_EBCDIC ? '' : 'big5',
43 'big5-hk' => $ON_EBCDIC ? '' : 'big5-hkscs',
46 for my $i (1..11,13..16){
47 $a2c{"ISO 8859 $i"} = "iso-8859-$i";
50 $a2c{"ISO Latin $i"} = "iso-8859-$Encode::Alias::Latin2iso[$i]";
52 for my $k (keys %Encode::Alias::Winlatin2cp){
53 my $v = $Encode::Alias::Winlatin2cp{$k};
54 $a2c{"Win" . ucfirst($k)} = "cp" . $v;
55 $a2c{"IBM-$v"} = $a2c{"MS-$v"} = "cp" . $v;
60 delete @Encode::ExtModule{
61 qw(euc-cn gb2312 gb12345 gbk cp936 iso-ir-165
62 euc-jp iso-2022-jp 7bit-jis shiftjis macjapan cp932
65 gb18030 big5plus euc-tw)
69 use Test::More tests => (scalar keys %a2c) * 3;
71 print "# alias test; \$ON_EBCDIC == $ON_EBCDIC\n";
73 foreach my $a (keys %a2c){
74 my $e = Encode::find_encoding($a);
75 is((defined($e) and $e->name), $a2c{$a});
78 # now we override some of the aliases and see if it works fine
80 define_alias(ascii => 'WinLatin1',
81 cyrillic => 'WinCyrillic',
82 arabic => 'WinArabic',
84 hebrew => 'WinHebrew');
86 @a2c{qw(ascii cyrillic arabic greek hebrew)} =
87 qw(cp1252 cp1251 cp1256 cp1253 cp1255);
90 define_alias( qr/shift.*jis$/i => '"macjapan"',
91 qr/sjis$/i => '"cp932"' );
92 @a2c{qw(Shift_JIS x-sjis)} = qw(macjapan cp932);
95 print "# alias test with alias overrides\n";
97 foreach my $a (keys %a2c){
98 my $e = Encode::find_encoding($a);
99 is((defined($e) and $e->name), $a2c{$a});
102 print "# alias undef test\n";
104 Encode::Alias->undef_aliases;
105 foreach my $a (keys %a2c){
106 my $e = Encode::find_encoding($a);
111 for (my $i = 0; $i < @Encode::Alias::Alias; $i+=2){
112 my ($k, $v) = @Encode::Alias::Alias[$i, $i+1];