String word = keyword;
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://titis.tistory.com/entry/java-인코딩-변환-한방에-해결
브라우저 별 인코딩 방식 바꾸기
keyword=keyword.trim();
String header = request.getHeader("User-Agent");try
{
if ((header.indexOf("Chrome") > -1) || (header.indexOf("Firefox") > -1) || (header.indexOf("Safari") > -1)
|| (header.indexOf("Opera") > -1)) {
keyword = new String(keyword.getBytes("iso-8859-1"), "utf-8");
} else if (header.indexOf("rv") > -1) {
keyword = new String(keyword.getBytes("iso-8859-1"), "euc-kr");
} else {
keyword = new String(keyword.getBytes("iso-8859-1"), "utf-8");
}
}catch(
UnsupportedEncodingException e)
{
e.printStackTrace();
}
'Interests [관심사] > Other Infor' 카테고리의 다른 글
Host 목록 확인 및 삭제 (0) | 2019.03.19 |
---|---|
SGE qsub, qstat, qdel 명령어 정리 (0) | 2019.03.19 |
리눅스 easy_install, pip 설치 (0) | 2019.03.19 |
Controller 와 jsp 간의 Ajax를 통한 동적 통신 (0) | 2019.03.19 |
엑셀 수식으로 줄 바꾸기, 한 줄 띄우기 CHAR 함수 ! (0) | 2019.01.18 |