summaryrefslogtreecommitdiff
path: root/src/test/java/TestUnicode.java
blob: a62389819a8f6fd31aa1baf29630f272dd0fa668 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

public class TestUnicode {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String str ="中国";
        String utf8 = new String(str.getBytes(StandardCharsets.UTF_8));
        System.out.println(utf8);

        String unicode = new String (str.getBytes(), StandardCharsets.UTF_8);
        System.out.println(unicode);
        String gbk = new String(unicode.getBytes("GBK"));
        System.out.println(gbk);
    }
}