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