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

汉字转unicode , 汉字转16进制

时间:2014-10-23 20:30:59      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   for   sp   div   log   amp   

 1 public static String toUnicode(String s)
 2     {
 3         String as[] = new String[s.length()];
 4         String s1 = "";
 5         for (int i = 0; i < s.length(); i++)
 6         {
 7             as[i] = Integer.toHexString(s.charAt(i) & 0xffff);
 8             s1 = s1 + as[i]+"\t";
 9         }
10         return s1;
11     }

 

 1 public static String toChineseHex(String s)
 2     {
 3         String ss = s;
 4         byte[] bt = ss.getBytes();
 5         String s1 = "";
 6         for (int i = 0; i < bt.length; i++)
 7         {
 8             String tempStr = Integer.toHexString(bt[i]);
 9             if (tempStr.length() > 2)
10                 tempStr = tempStr.substring(tempStr.length() - 2);
11             s1 = s1 + tempStr + " ";
12         }
13         return s1.toUpperCase();
14     }

 

汉字转unicode , 汉字转16进制

标签:style   blog   color   ar   for   sp   div   log   amp   

原文地址:http://www.cnblogs.com/stone1022/p/4046588.html

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