본문 바로가기

Java

(펌)JAVA - 한글 인코딩 변환 체크 한방에 끝내기

사이트 없어질까바 저장




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("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"));

 

출처 - http://gongam100.tistory.com/10


근데, 위에 내용이 인코딩을 변환해 주는 것이 아니라고??

  • 확인하세요 2015.03.26 16:25 신고 ADDR EDIT/DEL REPLY

    getBytes와 new String을 잘못 이해하고 작성된 글인듯 합니다.
    new String은 원하는 케릭터셋으로 변환하는것이 아닙니다.

  • 정말 2015.08.25 14:46 신고 ADDR EDIT/DEL REPLY

    엉망이네요



아래 글들을 보면 내가 저장한 인코딩을 내가 저장한 인코딩의 String  객체를 가져오는 것이라고 한다. 아직 테스트 할 사항이 많아 (properties), 내가 원하는 내용은 좀 더 확인 해보자...

자바 new String() 시 초보들이 하기 쉬운 실수...

http://blog.javarouka.me/2011/09/new-string.html




Java Character Set의 이해

http://kin.naver.com/knowhow/detail.nhn?docId=527939


'Java' 카테고리의 다른 글

(펌) java 로 tail 구현  (0) 2013.04.10
java exec 공백 파일 실행  (0) 2012.10.29
ResultSet 의 동작 구조  (0) 2011.06.17
디렉토리 존재 여부와 생성  (0) 2011.06.15
[펌] ResourceBundle  (0) 2011.05.30