Bytes("ISO8859-1"),"GBK")的实质

来源:互联网 发布:h3c交换机查看mac地址 编辑:程序博客网 时间:2024/05/21 22:58
import java.io.UnsupportedEncodingException;  public class main {      public static void main(String[] args) throws UnsupportedEncodingException{          byte [] b= new byte[]{(byte) 0xcc,(byte) 0xe1,(byte) 0xbd,(byte) 0xbb};          String s = new String(b,"ISO8859-1");          System.out.println(s);          print(s.getBytes("ISO8859-1"));          print(s.getBytes("GBK"));          print(s.getBytes("UTF-16"));          System.out.println(new String(s.getBytes("ISO8859-1"),"gbk"));          String ss = "中文";          print(ss.getBytes("UTF-16"));          print(ss.getBytes("ISO8859-1"));      }      static void print(byte [] b){          for(byte _b : b){              String s = Integer.toHexString(_b&0xff);              if(s.length()==1){                  s = "0"+s;              }              System.out.print(s + " ");          }          System.out.println();      }  }  
阅读全文
0 0
原创粉丝点击