Last change
on this file was 2, checked in by bird, 22 years ago |
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
File size:
1.4 KB
|
Line | |
---|
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.
|
---|
4 |
|
---|
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'
|
---|
12 | );
|
---|
13 |
|
---|
14 | if ($ARGV[0] eq '')
|
---|
15 | {
|
---|
16 | $file = 'character-sets';
|
---|
17 | if (! -f $file)
|
---|
18 | {
|
---|
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';
|
---|
21 | }
|
---|
22 | }
|
---|
23 | else
|
---|
24 | {
|
---|
25 | $file = $ARGV[0];
|
---|
26 | }
|
---|
27 |
|
---|
28 | open (INPUT, "< $file") || die "couldn't open $file: $!";
|
---|
29 |
|
---|
30 | $body = 0;
|
---|
31 | $current = '';
|
---|
32 | while (<INPUT>)
|
---|
33 | {
|
---|
34 | chop;
|
---|
35 | $body = 1 if /^Name:/;
|
---|
36 | next unless $body;
|
---|
37 |
|
---|
38 | if (/^$/)
|
---|
39 | {
|
---|
40 | $current = '';
|
---|
41 | next;
|
---|
42 | }
|
---|
43 |
|
---|
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);
|
---|
48 | if ($type eq 'Name:')
|
---|
49 | {
|
---|
50 | $current = $map{$name};
|
---|
51 | if ($current)
|
---|
52 | {
|
---|
53 | print " hash.put (\"$lower\", \"$current\");\n";
|
---|
54 | }
|
---|
55 | }
|
---|
56 | elsif ($type eq 'Alias:')
|
---|
57 | {
|
---|
58 | # The IANA list has some ugliness.
|
---|
59 | if ($name ne '' && $name ne 'NONE' && $current)
|
---|
60 | {
|
---|
61 | print " hash.put (\"$lower\", \"$current\");\n";
|
---|
62 | }
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | close (INPUT);
|
---|
Note:
See
TracBrowser
for help on using the repository browser.