首页 > 其他 > 详细

常用编码测试

时间:2014-07-19 12:26:21      阅读:213      评论:0      收藏:0      [点我收藏+]
 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

常用编码测试

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!