怎样将GB2312编码的字符串转换为ISO-8859-1编码的字符串?
import java.io.UnsupportedEncodingException;
/**
* 怎样将GB2312编码的字符串转换为ISO-8859-1编码的字符串?
* @author bin
*
*/
public class 编码转换 {
public static void main(String[] args) {
String s1 = "你好";
try {
String s2 = new String(s1.getBytes("GB2312"), "ISO-8859-1");
System.out.println(s2);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}