一、1,UTF编码 - 2,ISO解码 - 3,UTF编码 - 4,ISO解码

String ISO = "ISO-8859-1";
String UTF = "UTF-8";
String GBK = "GBK";
String string = "你好";
byte[] bytes = string.getBytes(UTF);
//1,UTF编码
for(byte b : bytes)
System.out.print(b + " ");
//-28 -67 -96 -27 -91 -67
string = new String(bytes,ISO);
//2,ISO解码
System.out.println(string);
//结果为6个"?"
bytes = string.getBytes(UTF);
//3,UTF编码
for(byte b : bytes)
System.out.print(b + " ");
//-61 -92 -62 -67 -62 -96 -61 -91 -62 -91 -62 -67(6个?编码为12个UTF)
string = new String(bytes,ISO);
//4,ISO解码
System.out.println("结果:"+string);
//结果:?¤??????????

二、1,UTF编码 - 2,GBK解码 - 3,UTF编码 - 4,GBK解码

String UTF = "UTF-8";
String GBK = "GBK";
String string = "你好";
byte[] bytes = string.getBytes(UTF);
//1,UTF编码
for(byte b : bytes)
System.out.print(b + " ");
//-28 -67 -96 -27 -91 -67
string = new String(bytes,GBK);
//2,GBK解码
System.out.println(string);
//浣犲ソ
bytes = string.getBytes(UTF);
//3,UTF编码
for(byte b : bytes)
System.out.print(b + " ");
//-26 -75 -93 -25 -118 -78 -29 -126 -67
string = new String(bytes,GBK);
//4,GBK解码
System.out.println(string);
//娴g姴銈?

三、1,GBK编码 - 2,UTF解码 - 3,UTF编码 - 4,GBK解码

String UTF = "UTF-8";
String GBK = "GBK";
String string = "你好";
byte[] bytes = string.getBytes(GBK);
//1,GBK编码
for(byte b : bytes)
System.out.print(b + " ");
//-60 -29 -70 -61
string = new String(bytes,UTF);
//2,UTF解码
System.out.println("结果:"+string);
//结果:3个"?"
bytes = string.getBytes(UTF);
//3,UTF编码
for(byte b : bytes)
System.out.print(b + " ");
//-17 -65 -67 -17 -65 -67 -17 -65 -67(已变)
string = new String(bytes,GBK);
System.out.println("结果:"+string);
//结果:锟斤拷锟?

最新文章

  1. CentOS 7 安装后没有ifconfig命令
  2. tp框架总结(三)
  3. Java(多态)动手动脑
  4. Subway Icon Set – 306个像素完美的特制图标
  5. ios WaxPatch热更新原理
  6. 从数据库导出数为生成excel表
  7. YII 配置文件
  8. 纯CSS3带动画效果导航菜单
  9. Linux使用问答
  10. IOC容器 - Autofac概述
  11. 数据结构(线段树):BZOJ 1568 [JSOI2008]Blue Mary开公司
  12. HibernateTemplate类的方法flush()
  13. 使用PowerDesigner创建数据库表图文并茂版
  14. Hadoop技巧(04):简易处理solr date 时区问题
  15. [进程管理]Load和CPU利用率是如何算出来的
  16. 浅谈使用git进行版本控制
  17. Flink RichSourceFunction应用,读关系型数据(mysql)数据写入关系型数据库(mysql)
  18. css概括
  19. 非关心数据库无法进行连表查询 所以我们需要在进行一对多查询时候 无法满足 因此需要在"1"的一方添加"多"的一方的的id 以便用于进行连表查询 ; 核心思想通过id进行维护与建文件
  20. Linux日志文件分割

热门文章

  1. UVALive 5984
  2. 快速切题 sgu118. Digital Root 秦九韶公式
  3. 使用简单的python语句编写爬虫 定时拿取信息并存入txt
  4. [工作]双核系统struts-config.xml
  5. js根据选中的复选框,隐藏那一行
  6. vector 函数都有哪些??
  7. 1.2 C++命名空间(namespace)
  8. [转]TFS.VisualStudio.com TF30063: You are not authorized to access Collection
  9. JSP--TOMCAT-MYSQL web页面查询
  10. SWIFT中计算两个日期间隔多少小时