编码解码:
public class app1{
public static void main(String []args)throws Exception{
String s1="abc";
String s2="def";
String s3=s1+s2;
System.out.println(s3);
String str ="aa,-b"+"def";
//编码
byte [] bytes=str.getBytes("ISO-8859-1");
//解码
System.out.println(new String(bytes,"GBK"));
System.out.println(bytes.length);
}
}
编码解码:反向编码,知道字节反向输出文字
//\0570b 是繁体國
//utf-8:國-->-27 -100 -117 3个字节表示
String guo="\u670b";
arr=guo.getBytes("utf-8");
//big5--> -80 -22 2个字节表示
arr=guo.getBytes("big5");
//new String() ,通过字符集byte[]进行解码,转变成字符串
System.out.println(new String(new byte[]{-80,-22},"big5"));
System.out.println(new String(big5,"big5"));
String asc="abcd中";
System.out.println(new String(asc.getBytes("big5"),"iso-8859-1"));