package report1; import java.io.UnsupportedEncodingException; public class CharacterIncoding { public static void main(String[] args) { String word = "무궁화 꽃이 피었습니다."; try { 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("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")); 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("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")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
'대학 생활 > JAVA' 카테고리의 다른 글
[JAVA] Java StringTokenizer 토큰으로 문자열 분리하기 (0) | 2015.04.17 |
---|---|
[JAVA] 리스트와 배열 간 복사 방법 (0) | 2015.04.08 |
[JAVA] equals, hashCode 메서드 함께 오버라이드하기. (0) | 2015.02.11 |
[JAVA] int to string 여러가지 방법 속도비교 (0) | 2015.02.08 |