This post contains affiliate marketing, and I may receive a commission at no additional cost to you. 이 포스팅은 제휴마케팅이 포함되어 일정의 커미션을 지급받습니다.
JAVA - 한글 인코딩 변환 체크 한방에 끝내기
String word = "안녕하세요."; System.out.println("utf-8 -> euc-kr : " + new String(word.getBytes("utf-8"), "euc-kr")); System.out.println("utf-8 -> ksc5601 : " + new String(word.getBytes("utf-8"), "ksc5601")); System.out.println("utf-8 -> x-windows-949 : " + new String(word.getBytes("utf-8"), "x-windows-949")); System.out.println("utf-8 -> iso-8859-1 : " + new String(word.getBytes("utf-8"), "iso-8859-1")); System.out.println("x-windows-949 -> euc-kr : " + new String(word.getBytes("x-windows-949"), "euc-kr")); System.out.println("x-windows-949 -> utf-8 : " + new String(word.getBytes("x-windows-949"), "utf-8")); System.out.println("x-windows-949 -> ksc5601 : " + new String(word.getBytes("x-windows-949"), "ksc5601")); System.out.println("x-windows-949 -> iso-8859-1 : " + new String(word.getBytes("x-windows-949"), "iso-8859-1")); System.out.println("euc-kr -> utf-8 : " + new String(word.getBytes("euc-kr"), "utf-8")); System.out.println("euc-kr -> ksc5601 : " + new String(word.getBytes("euc-kr"), "ksc5601")); System.out.println("euc-kr -> x-windows-949 : " + new String(word.getBytes("euc-kr"), "x-windows-949")); System.out.println("euc-kr -> iso-8859-1 : " + new String(word.getBytes("euc-kr"), "iso-8859-1")); System.out.println("ksc5601 -> euc-kr : " + new String(word.getBytes("ksc5601"), "euc-kr")); System.out.println("ksc5601 -> utf-8 : " + new String(word.getBytes("ksc5601"), "utf-8")); System.out.println("ksc5601 -> x-windows-949 : " + new String(word.getBytes("ksc5601"), "x-windows-949")); System.out.println("ksc5601 -> iso-8859-1 : " + new String(word.getBytes("ksc5601"), "iso-8859-1")); System.out.println("iso-8859-1 -> euc-kr : " + new String(word.getBytes("iso-8859-1"), "euc-kr")); System.out.println("iso-8859-1 -> ksc5601 : " + new String(word.getBytes("iso-8859-1"), "ksc5601")); System.out.println("iso-8859-1 -> x-windows-949 : " + new String(word.getBytes("iso-8859-1"), "x-windows-949")); System.out.println("iso-8859-1 -> utf-8 : " + new String(word.getBytes("iso-8859-1"), "utf-8")); |
'개발이야기 > Java' 카테고리의 다른 글
String to Date, Date to String 형변환 (0) | 2019.03.22 |
---|---|
자바(JAVA) 형 변환(String과 int) (0) | 2019.03.22 |