hbase中文内容编码转换

 

 1     /**
 2      * HBASE中文转换
 3      */
 4     @Test
 5     public void testHbaseStr() throws Exception {
 6 //        Hbase UTF8编码
 7         String content = "\\xE7\\x83\\xA6";
 8         char[] chars = content.toCharArray();
 9         StringBuffer sb = new StringBuffer();
10         for (int i = 2; i < chars.length; i = i + 4) {
11 //            System.out.println(chars[i]);
12             sb.append(chars[i]);
13 //            System.out.println(chars[i + 1]);
14             sb.append(chars[i + 1]);
15         }
16         System.out.println(sb);
17         String ouputStr = new String(Hex.decodeHex(sb.toString().toCharArray()), "UTF-8");
18         System.out.println(ouputStr);
19     }

 输出:

  E783A6
  烦

posted @ 2018-01-28 12:05  星瑞  阅读(3518)  评论(0编辑  收藏  举报