01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19: package org.apache.batik.util;
20:
21: import java.util.HashMap;
22: import java.util.Map;
23:
24: /**
25: * This class contains utility functions to manage encodings.
26: *
27: * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
28: * @version $Id: EncodingUtilities.java 478169 2006-11-22 14:23:24Z dvholten $
29: */
30: public class EncodingUtilities {
31:
32: /**
33: * The standard to Java encoding table.
34: */
35: protected static final Map ENCODINGS = new HashMap();
36: static {
37: ENCODINGS.put("UTF-8", "UTF8");
38: ENCODINGS.put("UTF-16", "Unicode");
39: ENCODINGS.put("US-ASCII", "ASCII");
40:
41: ENCODINGS.put("ISO-8859-1", "8859_1");
42: ENCODINGS.put("ISO-8859-2", "8859_2");
43: ENCODINGS.put("ISO-8859-3", "8859_3");
44: ENCODINGS.put("ISO-8859-4", "8859_4");
45: ENCODINGS.put("ISO-8859-5", "8859_5");
46: ENCODINGS.put("ISO-8859-6", "8859_6");
47: ENCODINGS.put("ISO-8859-7", "8859_7");
48: ENCODINGS.put("ISO-8859-8", "8859_8");
49: ENCODINGS.put("ISO-8859-9", "8859_9");
50: ENCODINGS.put("ISO-2022-JP", "JIS");
51:
52: ENCODINGS.put("WINDOWS-31J", "MS932");
53: ENCODINGS.put("EUC-JP", "EUCJIS");
54: ENCODINGS.put("GB2312", "GB2312");
55: ENCODINGS.put("BIG5", "Big5");
56: ENCODINGS.put("EUC-KR", "KSC5601");
57: ENCODINGS.put("ISO-2022-KR", "ISO2022KR");
58: ENCODINGS.put("KOI8-R", "KOI8_R");
59:
60: ENCODINGS.put("EBCDIC-CP-US", "Cp037");
61: ENCODINGS.put("EBCDIC-CP-CA", "Cp037");
62: ENCODINGS.put("EBCDIC-CP-NL", "Cp037");
63: ENCODINGS.put("EBCDIC-CP-WT", "Cp037");
64: ENCODINGS.put("EBCDIC-CP-DK", "Cp277");
65: ENCODINGS.put("EBCDIC-CP-NO", "Cp277");
66: ENCODINGS.put("EBCDIC-CP-FI", "Cp278");
67: ENCODINGS.put("EBCDIC-CP-SE", "Cp278");
68: ENCODINGS.put("EBCDIC-CP-IT", "Cp280");
69: ENCODINGS.put("EBCDIC-CP-ES", "Cp284");
70: ENCODINGS.put("EBCDIC-CP-GB", "Cp285");
71: ENCODINGS.put("EBCDIC-CP-FR", "Cp297");
72: ENCODINGS.put("EBCDIC-CP-AR1", "Cp420");
73: ENCODINGS.put("EBCDIC-CP-HE", "Cp424");
74: ENCODINGS.put("EBCDIC-CP-BE", "Cp500");
75: ENCODINGS.put("EBCDIC-CP-CH", "Cp500");
76: ENCODINGS.put("EBCDIC-CP-ROECE", "Cp870");
77: ENCODINGS.put("EBCDIC-CP-YU", "Cp870");
78: ENCODINGS.put("EBCDIC-CP-IS", "Cp871");
79: ENCODINGS.put("EBCDIC-CP-AR2", "Cp918");
80:
81: ENCODINGS.put("CP1252", "Cp1252");
82: }
83:
84: /**
85: * This class does not need to be instantiated.
86: */
87: protected EncodingUtilities() {
88: }
89:
90: /**
91: * Returns the Java encoding string mapped with the given standard
92: * encoding string.
93: * @return null if no mapping was found.
94: */
95: public static String javaEncoding(String encoding) {
96: return (String) ENCODINGS.get(encoding.toUpperCase());
97: }
98: }
|