◽ Java language/Java

[Java - (17) ] String 문자열 원하는 인코딩으로 변환하기

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
String proposer = "한글 테스트";
"utf-8 -> euc-kr            : "
     + new String(proposer.getBytes("utf-8"), "euc-kr"));
"utf-8 -> ksc5601           : "     + new String(proposer.getBytes("utf-8"), "ksc5601"));
"utf-8 -> x-windows-949     : " + new String(proposer.getBytes("utf-8"), "x-windows-949"));
"utf-8 -> iso-8859-1        : " + new String(proposer.getBytes("utf-8"), "iso-8859-1"));
"iso-8859-1 -> euc-kr       : " + new String(proposer.getBytes("iso-8859-1"), "euc-kr"));
"iso-8859-1 -> ksc5601      : " + new String(proposer.getBytes("iso-8859-1"), "ksc5601"));
"iso-8859-1 -> x-windows-949: " + new String(proposer.getBytes("iso-8859-1"), "x-windows-949"));
"iso-8859-1 -> utf-8        : " + new String(proposer.getBytes("iso-8859-1"), "utf-8"));
"euc-kr -> utf-8             : "     + new String(proposer.getBytes("euc-kr"), "utf-8"));
"euc-kr -> ksc5601           : "     + new String(proposer.getBytes("euc-kr"), "ksc5601"));
"euc-kr -> x-windows-949     : "     + new String(proposer.getBytes("euc-kr"), "x-windows-949"));
"euc-kr -> iso-8859-1        : "     + new String(proposer.getBytes("euc-kr"), "iso-8859-1"));
"ksc5601 -> euc-kr            : "     + new String(proposer.getBytes("ksc5601"), "euc-kr"));
"ksc5601 -> utf-8             : "     + new String(proposer.getBytes("ksc5601"), "utf-8"));
"ksc5601 -> x-windows-949     : "     + new String(proposer.getBytes("ksc5601"), "x-windows-949"));
"ksc5601 -> iso-8859-1        : "     + new String(proposer.getBytes("ksc5601"), "iso-8859-1"));
"x-windows-949 -> euc-kr    : " + new String(proposer.getBytes("x-windows-949"), "euc-kr"));
"x-windows-949 -> utf-8     : " + new String(proposer.getBytes("x-windows-949"), "utf-8"));
"x-windows-949 -> ksc5601   : " + new String(proposer.getBytes("x-windows-949"), "ksc5601"));
"x-windows-949 -> iso-8859-1: " + new String(proposer.getBytes("x-windows-949"), "iso-8859-1"));

 

푸터바