KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > util > EncodingUtilities


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

18 package org.apache.batik.util;
19
20 import java.util.HashMap JavaDoc;
21 import java.util.Map JavaDoc;
22
23 /**
24  * This class contains utility functions to manage encodings.
25  *
26  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
27  * @version $Id: EncodingUtilities.java,v 1.3 2004/08/18 07:15:48 vhardy Exp $
28  */

29 public class EncodingUtilities {
30     
31     /**
32      * The standard to Java encoding table.
33      */

34     protected final static Map JavaDoc ENCODINGS = new HashMap JavaDoc();
35     static {
36         ENCODINGS.put("UTF-8", "UTF8");
37         ENCODINGS.put("UTF-16", "Unicode");
38         ENCODINGS.put("US-ASCII", "ASCII");
39
40         ENCODINGS.put("ISO-8859-1", "8859_1");
41         ENCODINGS.put("ISO-8859-2", "8859_2");
42         ENCODINGS.put("ISO-8859-3", "8859_3");
43         ENCODINGS.put("ISO-8859-4", "8859_4");
44         ENCODINGS.put("ISO-8859-5", "8859_5");
45         ENCODINGS.put("ISO-8859-6", "8859_6");
46         ENCODINGS.put("ISO-8859-7", "8859_7");
47         ENCODINGS.put("ISO-8859-8", "8859_8");
48         ENCODINGS.put("ISO-8859-9", "8859_9");
49         ENCODINGS.put("ISO-2022-JP", "JIS");
50
51         ENCODINGS.put("WINDOWS-31J", "MS932");
52         ENCODINGS.put("EUC-JP", "EUCJIS");
53         ENCODINGS.put("GB2312", "GB2312");
54         ENCODINGS.put("BIG5", "Big5");
55         ENCODINGS.put("EUC-KR", "KSC5601");
56         ENCODINGS.put("ISO-2022-KR", "ISO2022KR");
57         ENCODINGS.put("KOI8-R", "KOI8_R");
58
59         ENCODINGS.put("EBCDIC-CP-US", "Cp037");
60         ENCODINGS.put("EBCDIC-CP-CA", "Cp037");
61         ENCODINGS.put("EBCDIC-CP-NL", "Cp037");
62     ENCODINGS.put("EBCDIC-CP-WT", "Cp037");
63         ENCODINGS.put("EBCDIC-CP-DK", "Cp277");
64         ENCODINGS.put("EBCDIC-CP-NO", "Cp277");
65         ENCODINGS.put("EBCDIC-CP-FI", "Cp278");
66         ENCODINGS.put("EBCDIC-CP-SE", "Cp278");
67         ENCODINGS.put("EBCDIC-CP-IT", "Cp280");
68         ENCODINGS.put("EBCDIC-CP-ES", "Cp284");
69         ENCODINGS.put("EBCDIC-CP-GB", "Cp285");
70         ENCODINGS.put("EBCDIC-CP-FR", "Cp297");
71         ENCODINGS.put("EBCDIC-CP-AR1", "Cp420");
72         ENCODINGS.put("EBCDIC-CP-HE", "Cp424");
73         ENCODINGS.put("EBCDIC-CP-BE", "Cp500");
74         ENCODINGS.put("EBCDIC-CP-CH", "Cp500");
75         ENCODINGS.put("EBCDIC-CP-ROECE", "Cp870");
76         ENCODINGS.put("EBCDIC-CP-YU", "Cp870");
77         ENCODINGS.put("EBCDIC-CP-IS", "Cp871");
78         ENCODINGS.put("EBCDIC-CP-AR2", "Cp918");
79
80         ENCODINGS.put("CP1252", "Cp1252");
81     }
82
83     /**
84      * This class does not need to be instantiated.
85      */

86     protected EncodingUtilities() {
87     }
88
89     /**
90      * Returns the Java encoding string mapped with the given standard
91      * encoding string.
92      * @return null if no mapping was found.
93      */

94     public static String JavaDoc javaEncoding(String JavaDoc encoding) {
95         return (String JavaDoc)ENCODINGS.get(encoding.toUpperCase());
96     }
97 }
98
Popular Tags