rebirth
发贴: 17
|
于 2004-09-02 17:03
关于转码问题,贴个简单的类上来方便使用。 public class CHARSET {
public CHARSET() { }
public static String ISO2GBK(String s) throws Exception { if(s == null || s.trim().equals("")) { return ""; } else { String s1 = new String(s.getBytes("ISO-8859-1"), "GBK"); return s1; } }
public static String ISO2GB2312(String s) throws Exception { if(s == null || s.trim().equals("")) { return ""; } else { String s1 = new String(s.getBytes("ISO-8859-1"), "GB2312"); return s1; } }
public static String ISO2BIG5(String s) throws Exception { if(s == null || s.trim().equals("")) { return s; } else { String s1 = new String(s.getBytes("ISO-8859-1"), "BIG5"); return s1; } }
public static String GBK2ISO(String s) throws Exception { if(s == null || s.trim().equals("")) { return s; } else { String s1 = new String(s.getBytes("GBK"), "ISO-8859-1"); return s1; } }
public static String GB23122ISO(String s) throws Exception { if(s == null || s.trim().equals("")) { return s; } else { String s1 = new String(s.getBytes("GB2312"), "ISO-8859-1"); return s1; } }
public static String BIG52ISO(String s) throws Exception { if(s == null || s.trim().equals("")) { return s; } else { String s1 = new String(s.getBytes("BIG5"), "ISO-8859-1"); return s1; } }
public static String GBK2BIG5(String s) throws Exception { if(s == null || s.trim().equals("")) { return s; } else { String s1 = ISO2BIG5(GBK2ISO(s)); return s1; } }
public static String GB23122BIG5(String s) throws Exception { if(s == null || s.trim().equals("")) { return s; } else { String s1 = ISO2BIG5(GB23122ISO(s)); return s1; } } }
rebirth edited on 2004-09-02 17:05
|