diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/scripts/encodings.pl | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libjava/scripts/encodings.pl')
-rw-r--r-- | libjava/scripts/encodings.pl | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/libjava/scripts/encodings.pl b/libjava/scripts/encodings.pl new file mode 100644 index 000000000..9af108769 --- /dev/null +++ b/libjava/scripts/encodings.pl @@ -0,0 +1,79 @@ +# encodings.pl - Download IANA text and compute alias list. +# Assumes you are running this program from gnu/gcj/convert/. +# Output suitable for direct inclusion in IOConverter.java. + +# Map IANA canonical names onto our canonical names. +%map = ( + 'ANSI_X3.4-1968' => 'ASCII', + 'ISO_8859-1:1987' => '8859_1', + 'UTF-8' => 'UTF8', + 'Shift_JIS' => 'SJIS', + 'Extended_UNIX_Code_Packed_Format_for_Japanese' => 'EUCJIS', + 'UTF16-LE' => 'UnicodeLittle', + 'UTF16-BE' => 'UnicodeBig' + ); + +if ($ARGV[0] eq '') +{ + $file = 'character-sets'; + if (! -f $file) + { + # Too painful to figure out how to get Perl to do it. + system 'wget -o .wget-log http://www.iana.org/assignments/character-sets'; + } +} +else +{ + $file = $ARGV[0]; +} + +# Include canonical names in the output. +foreach $key (keys %map) +{ + $output{lc ($key)} = $map{$key}; +} + +open (INPUT, "< $file") || die "couldn't open $file: $!"; + +$body = 0; +$current = ''; +while (<INPUT>) +{ + chop; + $body = 1 if /^Name:/; + next unless $body; + + if (/^$/) + { + $current = ''; + next; + } + + ($type, $name) = split (/\s+/); + # Encoding names are case-insensitive. We do all processing on + # the lower-case form. + my $lower = lc ($name); + if ($type eq 'Name:') + { + $current = $map{$name}; + if ($current) + { + $output{$lower} = $current; + } + } + elsif ($type eq 'Alias:') + { + # The IANA list has some ugliness. + if ($name ne '' && $lower ne 'none' && $current) + { + $output{$lower} = $current; + } + } +} + +close (INPUT); + +foreach $key (sort keys %output) +{ + print " hash.put (\"$key\", \"$output{$key}\");\n"; +} |