1 package com.thaiopensource.xml.util; 2 3 import java.io.UnsupportedEncodingException ; 4 5 public abstract class EncodingMap { 6 private static final String [] aliases = { 7 "UTF-8", "UTF8", 8 "UTF-16", "Unicode", 9 "UTF-16BE", "UnicodeBigUnmarked", 10 "UTF-16LE", "UnicodeLittleUnmarked", 11 "US-ASCII", "ASCII", 12 "TIS-620", "TIS620" 13 }; 14 15 static public String getJavaName(String enc) { 16 try { 17 "x".getBytes(enc); 18 } 19 catch (UnsupportedEncodingException e) { 20 for (int i = 0; i < aliases.length; i += 2) { 21 if (enc.equalsIgnoreCase(aliases[i])) { 22 try { 23 "x".getBytes(aliases[i + 1]); 24 return aliases[i + 1]; 25 } 26 catch (UnsupportedEncodingException e2) {} 27 } 28 } 29 } 30 return enc; 31 } 32 33 static public void main(String [] args) { 34 System.err.println(getJavaName(args[0])); 35 } 36 } 37 38 | Popular Tags |