JAVA 中字符编码问题

package test;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class StringDemo {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String s = "中国";
        byte[] bytes = s.getBytes("GBK");
        System.out.println(Arrays.toString(bytes));   //[-28, -72, -83, -27, -101, -67]
        String ss =new String(bytes,"GBK");
        System.out.println(ss);
    }
}

 

posted @ 2022-03-29 22:12  phpwyl  阅读(21)  评论(0编辑  收藏  举报