JAEYOUNG CHOI 님의 블로그에서 무단 펌한 글이다.
모든 String 은 기본적으로 file.encoding 을 따라간다.

- API -
string.getBytes(charset)

해당 stringcharset 인코딩 바이트 배열을 얻는다.
(다른 인코딩의 Writer 등에 바이트를 써야할 때 사용)

new String(bytes)
해당 bytes 를 file.encoding 인코딩 바이트 배열로 보고 string 을 만들어낸다.

new String(bytes, charset)
해당 bytescharset 인코딩 바이트 배열로 보고 string 을 만들어낸다.

솔린IX 님의 블로그에서 무단 펌한 글이다.
o(new String(word.getBytes("utf-8"), "euc-kr"));
o(new String(word.getBytes("utf-8"), "ksc5601"));
o(new String(word.getBytes("utf-8"), "x-windows-949"));
o(new String(word.getBytes("utf-8"), "iso-8859-1"));

o(new String(word.getBytes("iso-8859-1"), "euc-kr"));
o(new String(word.getBytes("iso-8859-1"), "ksc5601"));
o(new String(word.getBytes("iso-8859-1"), "x-windows-949"));
o(new String(word.getBytes("iso-8859-1"), "utf-8"));

o(new String(word.getBytes("euc-kr"), "ksc5601"));
o(new String(word.getBytes("euc-kr"), "utf-8"));
o(new String(word.getBytes("euc-kr"), "x-windows-949"));
o(new String(word.getBytes("euc-kr"), "iso-8859-1"));

o(new String(word.getBytes("ksc5601"), "euc-kr"));
o(new String(word.getBytes("ksc5601"), "utf-8"));
o(new String(word.getBytes("ksc5601"), "x-windows-949"));
o(new String(word.getBytes("ksc5601"), "iso-8859-1"));

o(new String(word.getBytes("x-windows-949"), "euc-kr"));
o(new String(word.getBytes("x-windows-949"), "utf-8"));
o(new String(word.getBytes("x-windows-949"), "ksc5601"));
o(new String(word.getBytes("x-windows-949"), "iso-8859-1"));

o 는
java : System.out.println 으로 바꾸면 됨.
jsp : out.println 으로 바꾸면 됨


java에 참 신기한거 많네... ^^;



+ Recent posts