码迷,mamicode.com
首页 > 其他好文 > 详细

常用编码测试

时间:2014-07-19 12:26:34      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   re   

 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     }

常用编码测试,布布扣,bubuko.com

常用编码测试

标签:style   blog   color   os   io   re   

原文地址:http://www.cnblogs.com/listened/p/3854642.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!