diff options
author | Tom Tromey <tromey@cygnus.com> | 2000-08-02 19:56:53 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2000-08-02 19:56:53 +0000 |
commit | f9427d170488c89fc8f2f4eed47b7feca4b32296 (patch) | |
tree | 0c8d1667b236d225c6148e9a0990ef2a665f3fca /libjava/gnu | |
parent | 5f51a7528fa1d1cee55a664b71dd3b3a08151ffc (diff) | |
download | gcc-f9427d170488c89fc8f2f4eed47b7feca4b32296.zip gcc-f9427d170488c89fc8f2f4eed47b7feca4b32296.tar.gz gcc-f9427d170488c89fc8f2f4eed47b7feca4b32296.tar.bz2 |
encodings.pl: New file.
* scripts/encodings.pl: New file.
* Makefile.in: Rebuilt.
* Makefile.am (convert_source_files): Added IOConverter.java.
* gnu/gcj/convert/UnicodeToBytes.java (UnicodeToBytes): Extend
IOConverter.
(getDefaultDecodingClass): Canonicalize default encoding name.
(getEncoder): Likewise.
* gnu/gcj/convert/BytesToUnicode.java (BytesToUnicode): Extend
IOConverter.
(getDefaultDecodingClass): Canonicalize default encoding name.
(getDecoder): Likewise.
* gnu/gcj/convert/IOConverter.java: New file.
From-SVN: r35432
Diffstat (limited to 'libjava/gnu')
-rw-r--r-- | libjava/gnu/gcj/convert/BytesToUnicode.java | 8 | ||||
-rw-r--r-- | libjava/gnu/gcj/convert/IOConverter.java | 52 | ||||
-rw-r--r-- | libjava/gnu/gcj/convert/UnicodeToBytes.java | 8 |
3 files changed, 62 insertions, 6 deletions
diff --git a/libjava/gnu/gcj/convert/BytesToUnicode.java b/libjava/gnu/gcj/convert/BytesToUnicode.java index 92836e0..d80ed65 100644 --- a/libjava/gnu/gcj/convert/BytesToUnicode.java +++ b/libjava/gnu/gcj/convert/BytesToUnicode.java @@ -8,7 +8,7 @@ details. */ package gnu.gcj.convert; -public abstract class BytesToUnicode +public abstract class BytesToUnicode extends IOConverter { /** Buffer to read bytes from. * The characters inbuffer[inpos] ... inbuffer[inlength-1] are available. */ @@ -25,7 +25,7 @@ public abstract class BytesToUnicode // Test (defaultDecodingClass == null) again in case of race condition. if (defaultDecodingClass == null) { - String encoding = System.getProperty("file.encoding"); + String encoding = canonicalize (System.getProperty("file.encoding")); String className = "gnu.gcj.convert.Input_"+encoding; try { @@ -60,7 +60,7 @@ public abstract class BytesToUnicode public static BytesToUnicode getDecoder (String encoding) throws java.io.UnsupportedEncodingException { - String className = "gnu.gcj.convert.Input_"+encoding; + String className = "gnu.gcj.convert.Input_" + canonicalize (encoding); Class decodingClass; try { @@ -71,6 +71,8 @@ public abstract class BytesToUnicode { try { + // We pass the original name to iconv and let it handle + // its own aliasing. return new Input_iconv (encoding); } catch (Throwable _) diff --git a/libjava/gnu/gcj/convert/IOConverter.java b/libjava/gnu/gcj/convert/IOConverter.java new file mode 100644 index 0000000..c986624 --- /dev/null +++ b/libjava/gnu/gcj/convert/IOConverter.java @@ -0,0 +1,52 @@ +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +/* This is a base class that handles aliasing issues for + UnicodeToBytes to BytesToUnicode. */ + +package gnu.gcj.convert; + +import java.util.Hashtable; + +public abstract class IOConverter +{ + // Map encoding aliases to our canonical form. + static private Hashtable hash = new Hashtable (); + + static + { + // Manually maintained aliases. Note that the value must be our + // canonical name. + hash.put ("ISO-Latin-1", "8859_1"); + // All aliases after this point are automatically generated by the + // `encodings.pl' script. Run it to make any corrections. + hash.put ("ISO_8859-1:1987", "8859_1"); + hash.put ("iso-ir-100", "8859_1"); + hash.put ("ISO_8859-1", "8859_1"); + hash.put ("ISO-8859-1", "8859_1"); + hash.put ("latin1", "8859_1"); + hash.put ("l1", "8859_1"); + hash.put ("IBM819", "8859_1"); + hash.put ("CP819", "8859_1"); + hash.put ("csISOLatin1", "8859_1"); + hash.put ("UTF-8", "UTF8"); + hash.put ("Shift_JIS", "SJIS"); + hash.put ("MS_Kanji", "SJIS"); + hash.put ("csShiftJIS", "SJIS"); + hash.put ("Extended_UNIX_Code_Packed_Format_for_Japanese", "EUCJIS"); + hash.put ("csEUCPkdFmtJapanese", "EUCJIS"); + hash.put ("EUC-JP", "EUCJIS"); + } + + // Turn an alias into the canonical form. + protected static final String canonicalize (String name) + { + String c = (String) hash.get (name); + return c == null ? name : c; + } +} diff --git a/libjava/gnu/gcj/convert/UnicodeToBytes.java b/libjava/gnu/gcj/convert/UnicodeToBytes.java index d068fce..1ba6ddf 100644 --- a/libjava/gnu/gcj/convert/UnicodeToBytes.java +++ b/libjava/gnu/gcj/convert/UnicodeToBytes.java @@ -8,7 +8,7 @@ details. */ package gnu.gcj.convert; -public abstract class UnicodeToBytes +public abstract class UnicodeToBytes extends IOConverter { /** Buffer to emit bytes to. * The locations buf[count] ... buf[buf.length-1] are available. */ @@ -22,7 +22,7 @@ public abstract class UnicodeToBytes // Test (defaultEncodingClass == null) again in case of race condition. if (defaultEncodingClass == null) { - String encoding = System.getProperty("file.encoding"); + String encoding = canonicalize (System.getProperty("file.encoding")); String className = "gnu.gcj.convert.Output_"+encoding; try { @@ -58,7 +58,7 @@ public abstract class UnicodeToBytes public static UnicodeToBytes getEncoder (String encoding) throws java.io.UnsupportedEncodingException { - String className = "gnu.gcj.convert.Output_"+encoding; + String className = "gnu.gcj.convert.Output_" + canonicalize (encoding); Class encodingClass; try { @@ -69,6 +69,8 @@ public abstract class UnicodeToBytes { try { + // We pass the original name to iconv and let it handle + // its own aliasing. return new Output_iconv (encoding); } catch (Throwable _) |