01: package org.kohsuke.rngom.xml.util;
02:
03: import java.io.UnsupportedEncodingException;
04:
05: public abstract class EncodingMap {
06: private static final String[] aliases = { "UTF-8", "UTF8",
07: "UTF-16", "Unicode", "UTF-16BE", "UnicodeBigUnmarked",
08: "UTF-16LE", "UnicodeLittleUnmarked", "US-ASCII", "ASCII",
09: "TIS-620", "TIS620" };
10:
11: static public String getJavaName(String enc) {
12: try {
13: "x".getBytes(enc);
14: } catch (UnsupportedEncodingException e) {
15: for (int i = 0; i < aliases.length; i += 2) {
16: if (enc.equalsIgnoreCase(aliases[i])) {
17: try {
18: "x".getBytes(aliases[i + 1]);
19: return aliases[i + 1];
20: } catch (UnsupportedEncodingException e2) {
21: }
22: }
23: }
24: }
25: return enc;
26: }
27:
28: static public void main(String[] args) {
29: System.err.println(getJavaName(args[0]));
30: }
31: }
|