编码转化

mac2022-06-30  85

已知String s;

1. 把String转换成数组:

Byte[] a = s.getBytes("iso-8859-1");

2.把字节数组转换成String:

String str = new String(a,"gbk");

3.综上:把原本中文乱码转换为中文:

String string = new String(s.getBytes("iso-8859-1"),"gbk");

转载于:https://www.cnblogs.com/yanjunwu/archive/2012/09/24/2700669.html

相关资源:文本文件编码转换工具 gbk utf8 gb2312
最新回复(0)