1 # encodings.pl - Download IANA text and compute alias list.
2 # Assumes you are running this program from gnu/gcj/convert/.
3 # Output suitable for direct inclusion in IOConverter.java.
5 # Map IANA canonical names onto our canonical names.
7 'ANSI_X3.4-1968' => 'ASCII',
8 'ISO_8859-1:1987' => '8859_1',
10 'Shift_JIS' => 'SJIS',
11 'Extended_UNIX_Code_Packed_Format_for_Japanese' => 'EUCJIS',
12 'UTF16-LE' => 'UnicodeLittle',
13 'UTF16-BE' => 'UnicodeBig'
18 $file = 'character-sets';
21 # Too painful to figure out how to get Perl to do it.
22 system 'wget -o .wget-log http://www.iana.org/assignments/character-sets';
30 # Include canonical names in the output.
31 foreach $key (keys %map)
33 $output{lc ($key)} = $map{$key};
36 open (INPUT
, "< $file") || die "couldn't open $file: $!";
43 $body = 1 if /^Name:/;
52 ($type, $name) = split (/\s+/);
53 # Encoding names are case-insensitive. We do all processing on
54 # the lower-case form.
55 my $lower = lc ($name);
58 $current = $map{$name};
61 $output{$lower} = $current;
64 elsif ($type eq 'Alias:')
66 # The IANA list has some ugliness.
67 if ($name ne '' && $lower ne 'none' && $current)
69 $output{$lower} = $current;
76 foreach $key (sort keys %output)
78 print " hash.put (\"$key\", \"$output{$key}\");\n";