GB2312编码的字符串如何转换为ISO-8859-1编码?


package constxiong.interview;

import java.io.UnsupportedEncodingException;

/**
 * 字符串字符集转换
 * @author ConstXiong
 * @date 2019-11-01 10:57:34
 */
public class TestCharsetConvert {

	public static void main(String[] args) throws UnsupportedEncodingException {
		String str = "爱编程";
		String strIso = new String(str.getBytes("GB2312"), "ISO-8859-1");
		System.out.println(strIso);
	}
}

 

   

来一道刷了进BAT的面试题?


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM