source: trunk/gcc/libjava/gnu/gcj/convert/IOConverter.java

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: 2.5 KB
Line 
1/* Copyright (C) 2000, 2001 Free Software Foundation
2
3 This file is part of libgcj.
4
5This software is copyrighted work licensed under the terms of the
6Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7details. */
8
9/* This is a base class that handles aliasing issues for
10 UnicodeToBytes to BytesToUnicode. */
11
12package gnu.gcj.convert;
13
14import java.util.Hashtable;
15
16public abstract class IOConverter
17{
18 // Map encoding aliases to our canonical form.
19 static private Hashtable hash = new Hashtable ();
20
21 // True if we have to do byte-order conversions on iconv()
22 // arguments.
23 static protected boolean iconv_byte_swap;
24
25 static
26 {
27 // Manually maintained aliases. Note that the value must be our
28 // canonical name.
29 hash.put ("iso-latin-1", "8859_1");
30 hash.put ("iso8859_1", "8859_1");
31 // On Solaris the default encoding, as returned by nl_langinfo(),
32 // is `646' (aka ASCII), but the Solaris iconv_open() doesn't
33 // understand that. We work around the problem by adding an
34 // explicit alias for Solaris users.
35 hash.put ("646", "ASCII");
36 // All aliases after this point are automatically generated by the
37 // `encodings.pl' script. Run it to make any corrections.
38 hash.put ("ansi_x3.4-1968", "ASCII");
39 hash.put ("iso-ir-6", "ASCII");
40 hash.put ("ansi_x3.4-1986", "ASCII");
41 hash.put ("iso_646.irv:1991", "ASCII");
42 hash.put ("ascii", "ASCII");
43 hash.put ("iso646-us", "ASCII");
44 hash.put ("us-ascii", "ASCII");
45 hash.put ("us", "ASCII");
46 hash.put ("ibm367", "ASCII");
47 hash.put ("cp367", "ASCII");
48 hash.put ("csascii", "ASCII");
49 hash.put ("iso_8859-1:1987", "8859_1");
50 hash.put ("iso-ir-100", "8859_1");
51 hash.put ("iso_8859-1", "8859_1");
52 hash.put ("iso-8859-1", "8859_1");
53 hash.put ("latin1", "8859_1");
54 hash.put ("l1", "8859_1");
55 hash.put ("ibm819", "8859_1");
56 hash.put ("cp819", "8859_1");
57 hash.put ("csisolatin1", "8859_1");
58 hash.put ("utf-8", "UTF8");
59 hash.put ("none", "UTF8");
60 hash.put ("shift_jis", "SJIS");
61 hash.put ("ms_kanji", "SJIS");
62 hash.put ("csshiftjis", "SJIS");
63 hash.put ("extended_unix_code_packed_format_for_japanese", "EUCJIS");
64 hash.put ("cseucpkdfmtjapanese", "EUCJIS");
65 hash.put ("euc-jp", "EUCJIS");
66
67 iconv_byte_swap = iconv_init ();
68 }
69
70 private static native boolean iconv_init ();
71
72 // Turn an alias into the canonical form.
73 protected static final String canonicalize (String name)
74 {
75 String c = (String) hash.get (name.toLowerCase ());
76 return c == null ? name : c;
77 }
78}
Note: See TracBrowser for help on using the repository browser.