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'
16 $file = 'character-sets';
19 # Too painful to figure out how to get Perl to do it.
20 system 'wget -o .wget-log http://www.iana.org/assignments/character-sets';
28 open (INPUT
, "< $file") || die "couldn't open $file: $!";
35 $body = 1 if /^Name:/;
44 ($type, $name) = split (/\s+/);
45 # Encoding names are case-insensitive. We do all processing on
46 # the lower-case form.
47 my $lower = lc ($name);
50 $current = $map{$name};
53 print " hash.put (\"$lower\", \"$current\");\n";
56 elsif ($type eq 'Alias:')
58 # The IANA list has some ugliness.
59 if ($name ne '' && $name ne 'NONE' && $current)
61 print " hash.put (\"$lower\", \"$current\");\n";