* cppfiles.c (_cpp_execute_include): Move `len` initialisation
[official-gcc.git] / libjava / scripts / encodings.pl
blob4c7f0579534e750ff63ccd8c5125bb3e294908a1
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.
6 %map = (
7 'ANSI_X3.4-1968' => 'ASCII',
8 'ISO_8859-1:1987' => '8859_1',
9 'UTF-8' => 'UTF8',
10 'Shift_JIS' => 'SJIS',
11 'Extended_UNIX_Code_Packed_Format_for_Japanese' => 'EUCJIS'
14 if ($ARGV[0] eq '')
16 $file = 'character-sets';
17 if (! -f $file)
19 # Too painful to figure out how to get Perl to do it.
20 system 'wget -o .wget-log http://www.isi.edu/in-notes/iana/assignments/character-sets';
23 else
25 $file = $ARGV[0];
28 open (INPUT, "< $file") || die "couldn't open $file: $!";
30 $body = 0;
31 $current = '';
32 while (<INPUT>)
34 chop;
35 $body = 1 if /^Name:/;
36 next unless $body;
38 if (/^$/)
40 $current = '';
41 next;
44 ($type, $name) = split (/\s+/);
45 if ($type eq 'Name:')
47 $current = $map{$name};
48 if ($current)
50 print " hash.put (\"$name\", \"$current\");\n";
53 elsif ($type eq 'Alias:')
55 # The IANA list has some ugliness.
56 if ($name ne '' && $name ne 'NONE' && $current)
58 print " hash.put (\"$name\", \"$current\");\n";
63 close (INPUT);