1 17 18 19 20 package org.apache.lenya.xml; 21 22 import java.util.Hashtable ; 23 24 25 29 public class XMLEncToJavaEnc extends Hashtable { 30 private static String DEFAULT_ENCODING = "utf-8"; 31 32 private XMLEncToJavaEnc() { 33 put("ascii", "ASCII"); 37 put("iso-8859-1", "ISO8859_1"); put("iso-8859-2", "ISO8859_2"); 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"); 48 put("cp-874", "Cp874"); 50 put("cp-950", "Cp950"); put("cp-1250", "Cp1250"); put("cp-1251", "Cp1251"); put("cp-1252", "Cp1252"); put("cp-1253", "Cp1253"); put("cp-1255", "Cp1255"); put("cp-1256", "Cp1256"); put("cp-1257", "Cp1257"); put("cp-1258", "Cp1258"); put("euc-jp", "EUC_JP"); put("euc-kr", "EUC_KR"); 63 put("iso-2022-jp", "ISO2022JP"); put("iso-2022-kr", "ISO2022KR"); 66 put("koi8-r", "KOI8_R"); put("shift_jis", "SJIS"); 69 put("utf-8", "UTF8"); 70 71 put("euc-tw", "EUC_TW"); put("x-mac-roman", "MacRoman"); put("x-mac-ce", "MacCentralEurope"); put("x-mac-greek", "MacGreek"); put("x-mac-turkish", "MacTurkish"); put("x-mac-cyrillic", "MacCyrillic"); } 78 79 84 public static void main(String [] args) { 85 System.out.println(XMLEncToJavaEnc.getJava("utf-8")); 86 } 87 88 95 public static String getJava(String xmlencoding) { 96 97 try { 98 return ((String ) ((new XMLEncToJavaEnc()).get(xmlencoding.toLowerCase()))); 99 } catch (Exception e) { 100 System.err.println("Unsupported Encoding; reverting to " + DEFAULT_ENCODING); 101 102 return DEFAULT_ENCODING; 103 } 104 } 105 } 106 | Popular Tags |