KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > xml > XMLEncToJavaEnc


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: XMLEncToJavaEnc.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.xml;
21
22 import java.util.Hashtable JavaDoc;
23
24
25 /**
26  * DOCUMENT ME!
27  * @deprecated
28  */

29 public class XMLEncToJavaEnc extends Hashtable JavaDoc {
30     private static String JavaDoc DEFAULT_ENCODING = "utf-8";
31
32     private XMLEncToJavaEnc() {
33         // JAVA supports a lot more...
34
// http://www.w3.org/International/O-charset-list.html
35
//
36
put("ascii", "ASCII");
37         put("iso-8859-1", "ISO8859_1"); // Latin 1
38
put("iso-8859-2", "ISO8859_2"); // Latin 2
39
put("iso-8859-3", "ISO8859_3");
40         put("iso-8859-4", "ISO8859_4");
41         put("iso-8859-5", "ISO8859_5");
42         put("iso-8859-6", "ISO8859_6");
43         put("iso-8859-7", "ISO8859_7");
44         put("iso-8859-8", "ISO8859_8");
45         put("iso-8859-9", "ISO8859_9");
46         put("big-5", "Big5"); // Traditional Chinese
47

48         put("cp-874", "Cp874"); // IBM Thai
49

50         //put("cp-932",???);
51
put("cp-950", "Cp950"); // PC Chinese (Hongkong, Taiwan)
52
put("cp-1250", "Cp1250"); // Windows Eastern Europe
53
put("cp-1251", "Cp1251"); // Windows Cyrillic
54
put("cp-1252", "Cp1252"); // Windows Latin 1
55
put("cp-1253", "Cp1253"); // Windows Greek
56
put("cp-1255", "Cp1255"); // Windows Hebrew
57
put("cp-1256", "Cp1256"); // Windows Arabic
58
put("cp-1257", "Cp1257"); // Windows Baltic
59
put("cp-1258", "Cp1258"); // Windows Vietnamese
60
put("euc-jp", "EUC_JP"); // JIS0201, 0208, 0212, EUC Encoding, Japanese
61
put("euc-kr", "EUC_KR"); // KS C 5601, EUC Encoding, Korean
62

63         put("iso-2022-jp", "ISO2022JP"); // JIS0201, 0208, 0212, ISO2022 Encoding, Japanese
64
put("iso-2022-kr", "ISO2022KR"); // ISO 2022 KR, Korean
65

66         put("koi8-r", "KOI8_R"); // KOI8-R, Russian
67
put("shift_jis", "SJIS"); // Shift-JIS, Japanese
68

69         put("utf-8", "UTF8");
70
71         put("euc-tw", "EUC_TW"); // CNS11643 (Plane 1-3), T. Chinese, EUC encoding
72
put("x-mac-roman", "MacRoman"); // Macintosh Roman
73
put("x-mac-ce", "MacCentralEurope"); // Macintosh Latin-2
74
put("x-mac-greek", "MacGreek"); // Macintosh Greek
75
put("x-mac-turkish", "MacTurkish"); // Macintosh Turkish
76
put("x-mac-cyrillic", "MacCyrillic"); // Macintosh Cyrillic
77
}
78
79     /**
80      * DOCUMENT ME!
81      *
82      * @param args DOCUMENT ME!
83      */

84     public static void main(String JavaDoc[] args) {
85         System.out.println(XMLEncToJavaEnc.getJava("utf-8"));
86     }
87
88     /**
89      * DOCUMENT ME!
90      *
91      * @param xmlencoding DOCUMENT ME!
92      *
93      * @return DOCUMENT ME!
94      */

95     public static String JavaDoc getJava(String JavaDoc xmlencoding) {
96
97         try {
98             return ((String JavaDoc) ((new XMLEncToJavaEnc()).get(xmlencoding.toLowerCase())));
99         } catch (Exception JavaDoc e) {
100             System.err.println("Unsupported Encoding; reverting to " + DEFAULT_ENCODING);
101
102             return DEFAULT_ENCODING;
103         }
104     }
105 }
106
Popular Tags