mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-23 00:29:45 +08:00
f92351d76e
* scripts/encodings.pl: Added `ASCII' alias. * Makefile.in: Rebuilt. * Makefile.am (convert_source_files): Added new files. * gnu/gcj/convert/Input_ASCII.java: New file. * gnu/gcj/convert/Output_ASCII.java: New file. * gnu/gcj/convert/Output_8859_1.java (write): Use `?' to represent out-of-range characters. * gnu/gcj/convert/natIconv.cc (iconv_init): New method. (read): Swap bytes if required. Treat `count' as character count, not byte count. (write): Likewise. Also, handle case where iconv fails on a given character. (init): Put encoding into exception. * gnu/gcj/convert/IOConverter.java (iconv_byte_swap): New global. (static): Call iconv_init. Rebuilt alias list. (iconv_init): New private method. From-SVN: r37190
64 lines
1.2 KiB
Perl
64 lines
1.2 KiB
Perl
# 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'
|
|
);
|
|
|
|
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.isi.edu/in-notes/iana/assignments/character-sets';
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$file = $ARGV[0];
|
|
}
|
|
|
|
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+/);
|
|
if ($type eq 'Name:')
|
|
{
|
|
$current = $map{$name};
|
|
if ($current)
|
|
{
|
|
print " hash.put (\"$name\", \"$current\");\n";
|
|
}
|
|
}
|
|
elsif ($type eq 'Alias:')
|
|
{
|
|
# The IANA list has some ugliness.
|
|
if ($name ne '' && $name ne 'NONE' && $current)
|
|
{
|
|
print " hash.put (\"$name\", \"$current\");\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
close (INPUT);
|