2001-06-26 12:36:47 +08:00
|
|
|
/* Copyright (C) 2000, 2001 Free Software Foundation
|
2000-08-03 03:56:53 +08:00
|
|
|
|
|
|
|
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 ();
|
|
|
|
|
2000-11-02 01:00:02 +08:00
|
|
|
// True if we have to do byte-order conversions on iconv()
|
|
|
|
// arguments.
|
|
|
|
static protected boolean iconv_byte_swap;
|
|
|
|
|
2000-08-03 03:56:53 +08:00
|
|
|
static
|
|
|
|
{
|
|
|
|
// Manually maintained aliases. Note that the value must be our
|
|
|
|
// canonical name.
|
2001-06-28 05:56:08 +08:00
|
|
|
hash.put ("iso-latin-1", "8859_1");
|
2000-08-03 03:56:53 +08:00
|
|
|
// All aliases after this point are automatically generated by the
|
|
|
|
// `encodings.pl' script. Run it to make any corrections.
|
2001-06-26 12:36:47 +08:00
|
|
|
hash.put ("ansi_x3.4-1968", "ASCII");
|
2000-11-02 01:00:02 +08:00
|
|
|
hash.put ("iso-ir-6", "ASCII");
|
2001-06-26 12:36:47 +08:00
|
|
|
hash.put ("ansi_x3.4-1986", "ASCII");
|
|
|
|
hash.put ("iso_646.irv:1991", "ASCII");
|
|
|
|
hash.put ("ascii", "ASCII");
|
|
|
|
hash.put ("iso646-us", "ASCII");
|
|
|
|
hash.put ("us-ascii", "ASCII");
|
2000-11-02 01:00:02 +08:00
|
|
|
hash.put ("us", "ASCII");
|
2001-06-26 12:36:47 +08:00
|
|
|
hash.put ("ibm367", "ASCII");
|
2000-11-02 01:00:02 +08:00
|
|
|
hash.put ("cp367", "ASCII");
|
2001-06-26 12:36:47 +08:00
|
|
|
hash.put ("csascii", "ASCII");
|
|
|
|
hash.put ("iso_8859-1:1987", "8859_1");
|
2000-08-03 03:56:53 +08:00
|
|
|
hash.put ("iso-ir-100", "8859_1");
|
2001-06-26 12:36:47 +08:00
|
|
|
hash.put ("iso_8859-1", "8859_1");
|
|
|
|
hash.put ("iso-8859-1", "8859_1");
|
2000-08-03 03:56:53 +08:00
|
|
|
hash.put ("latin1", "8859_1");
|
|
|
|
hash.put ("l1", "8859_1");
|
2001-06-26 12:36:47 +08:00
|
|
|
hash.put ("ibm819", "8859_1");
|
|
|
|
hash.put ("cp819", "8859_1");
|
|
|
|
hash.put ("csisolatin1", "8859_1");
|
|
|
|
hash.put ("utf-8", "UTF8");
|
|
|
|
hash.put ("none", "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");
|
2000-11-02 01:00:02 +08:00
|
|
|
|
|
|
|
iconv_byte_swap = iconv_init ();
|
2000-08-03 03:56:53 +08:00
|
|
|
}
|
|
|
|
|
2000-11-02 01:00:02 +08:00
|
|
|
private static native boolean iconv_init ();
|
|
|
|
|
2000-08-03 03:56:53 +08:00
|
|
|
// Turn an alias into the canonical form.
|
|
|
|
protected static final String canonicalize (String name)
|
|
|
|
{
|
2001-06-26 12:36:47 +08:00
|
|
|
String c = (String) hash.get (name.toLowerCase ());
|
2000-08-03 03:56:53 +08:00
|
|
|
return c == null ? name : c;
|
|
|
|
}
|
|
|
|
}
|