/**
* 将一个原来给定的String,转换成对应的gb2312编码的char[];
*
* @param instr
* @return
*/
public static char[] toGB2312(String instr) {
try {
byte temp[] = instr.getBytes("GB2312"); // 将instr转换成一个gb2312编码的byte[]
char ret[] = new char[temp.length + 1];
int i = 0;
for (i = 0; i < temp.length; i++) {
ret[i] = (char) temp[i];
}
ret[i] = '\0';
return ret;
} catch (Exception e) {
return new char[0];
}
}