package db;
import java.io.UnsupportedEncodingException;
public class ChangeChar {
public ChangeChar() {
}
public static String Char(String str) {
String value = "";
String check = System.getProperty("os.name").toLowerCase();
if (str != null)
try {
if (check.indexOf("win") != -1) {
value = new String(str.getBytes("ISO-8859-1"));
} else {
value = new String(str.getBytes(), "GB2312");
}
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}
return value;
}
public String gb2iso(String qs) {
try {
if (qs == null)
return "NULL";
else
return new String(qs.getBytes("gb2312"), "iso-8859-1");
} catch (Exception e) {
}
return "NULL";
}
public String Convert(String s){
String result = null;
byte[] temp = null ;
try {
temp = s.getBytes("iso-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
try {
result = new String(temp,"utf-8");
} catch (UnsupportedEncodingException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
return result;
}
public String Convert1(String s){
String result = null;
byte[] temp = null ;
try {
temp = s.getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
try {
result = new String(temp,"iso-8859-1");
} catch (UnsupportedEncodingException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
return result;
}
}