인코딩

2021. 10. 28. 10:24내가 보려고

utf-8로 인코딩된 파일을 윈도우 서버에서 컴파일할 경우 문자가 깨지는 현상

 -> utf-8로 인코딩된 파일을 윈도우 기본 인코딩을 따라 ms949 방식으로 읽으려고해서 나는 에러

 

utf-8과 ms949와 같은 한글 인코딩은  1바이트로 표시되는 ascii문자에서만 서로 호환성을 가질 뿐이라서 영문자들은 잘 표시되지만 한글은 깨짐

 

URLEncoder.encode("텍스트", "utf-8")


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

출처 : https://chirow.tistory.com/404

 


 

문자열 인코딩 개념 정리(ASCII/ANSI/EUC-KR/CP949/UTF-8/UNICODE)

 

문자열 인코딩 개념 정리(ASCII/ANSI/EUC-KR/CP949/UTF-8/UNICODE)

지금껏 개발을 해오면서 ASCII와 ANSI의 차이에 대해 깊게 생각해 본 적이 없었다. UTF-8 기본으로 하여 개발을 해왔던 이유도 있거니와 ASCII=ANSI로 생각해도 사실 큰 문제는 없어왔다. 점 하나 그냥

onlywis.tistory.com

출처 https://onlywis.tistory.com/2


 

 

 

'내가 보려고' 카테고리의 다른 글

둘러볼 블로그  (0) 2022.01.06
카카오 링크, 문자보내기  (0) 2021.12.03
[javascript] slice() 와 splilce()  (0) 2021.04.06