java吧 关注:1,235,433贴子:12,703,391
  • 1回复贴,共1

乱码 问题,有大神能回答我嘛?

只看楼主收藏回复

public static void main(String[] args){
try {
// 以下 是 普通货物 的UTF-8 字节
byte[] data = new byte[] {-26, -103, -82, -23, -128, -102, -24, -76, -89, -25, -119, -87};
new String(data,"UTF-8");
String u = new String(data,"UTF-8");
System.out.println(u);
byte[] uc = u.getBytes("UTF-8");
for(int i =0 ;uc.length>i;i++) {
System.out.print("\t"+(new Integer(uc[i])).toString() + ",");
}
System.out.println("");
String a = new String(data,"GBK");
byte[] c = a.getBytes("GBK");
for(int i =0 ;c.length>i;i++) {
System.out.print("\t"+(new Integer(c[i])).toString() + ",");
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
那么 为何 乱码 GBK 却不能把 字节还原回去


IP属地:广东1楼2018-03-09 15:13回复
    没人?


    IP属地:广东2楼2018-03-09 15:28
    回复