常用コードテスト


 1 public static void main(String[] args) {

 2         String s = " ";

 3         String cn = "";

 4         System.out.println("src: " + s);

 5          try {

 6              

 7             byte[] bs = s.getBytes("utf-8");

 8             System.out.println(Arrays.toString(bs));;

 9             //[-28, -67, -96, -27, -91, -67]

10             cn = new String(bs, "utf-8");

11             System.out.println(cn);

12             // 

13             cn = new String(bs, "gbk");

14             System.out.println(cn);

15             //

16             

17             bs = s.getBytes("gbk");

18             System.out.println(Arrays.toString(bs));

19             //[-60, -29, -70, -61]

20             

21             cn = new String(bs, "gbk");

22             System.out.println(cn);

23             // 

24             cn = new String(bs, "utf-8");

25             System.out.println(cn);

26             //???

27         } catch (UnsupportedEncodingException e) {

28             e.printStackTrace();

29         }

30     }