这个字符集和具体的数据库os都有关系的了!
package hdjy.userrankmanage.common;
/**
* @author NiuXiaoGuo
* @version 1.31
* @date 2002/06/21
*/
import java.io.*;
public class TransFormat {
public static String GBToUnicode(String strIn) {
String strOut2 = null;
if (strIn == null || (strIn.trim()).equals(""))
return strIn;
try {
byte[] b = strIn.getBytes("ISO8859_1");
strOut2 = new String(b, "GB2312");
} catch (Exception e) {
}
return strOut2;
}
public static String unicodeToGB(String strIn) {
byte[] b;
String strOut = null;
if (strIn == null || (strIn.trim()).equals(""))
return strIn;
try {
b = strIn.getBytes("GB2312");
strOut = new String(b, "ISO8859_1");
} catch (UnsupportedEncodingException e) {
}
return strOut;
}
}