转换程序:
public String AsciiToChineseString(String s){
char[] orig = s.toCharArray();
byte[] dest = new byte[orig.length];
for (int i=0;i<dest.length;i++) dest=(byte)(orig&0xFF);
try {
sun.io.ByteToCharConverter toChar = sun.io.ByteToCharConverter.getConverter("gb2312");
return new String(toChar.convertAll(dest));
}
catch (Exception e){
System.out.println(e);
return s;
}
}
public String ChineseStringToAscii(String s){
try {
sun.io.CharToByteConverter toByte = sun.io.CharToByteConverter.getConverter("gb2312");
byte[] orig = toByte.convertAll(s.toCharArray());
char[] dest = new char[orig.length];
for (int i=0;i<dest.length;i++) dest=(char)(orig&0xFF);
return new String(dest);
}
catch (Exception e) {
System.out.println(e);
return s;
}
}