Java编码

将GB2312编码的字符串转换为ISO-8859-1编码的字符串

public class Test {
    public static void main(String[] args) {
        System.out.println();
        String s1 = "你好";
        try {
            String s2 = new String(s1.getBytes("GB2312"), "ISO-8859-1");
            System.out.println(s2);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
}

 

posted @ 2019-05-26 19:34  Cool_Yang  阅读(194)  评论(0编辑  收藏  举报