문서의 이전 판입니다!
* java환경에서는 euc-kr이 KSC5601-87로 사용되어 CP949의 확장 완성형과 호환되지 않을 수도 있으니 주의해야 합니다. * [[http://helloworld.naver.com/helloworld/19187|hello world » 한글 인코딩의 이해 1편: 한글 인코딩의 역사와 유니코드]] * [[http://helloworld.naver.com/helloworld/76650|hello world » 한글 인코딩의 이해 2편: 유니코드와 Java를 이용한 한글 처리]] * [[http://www.utf8-chartable.de/unicode-utf8-table.pl|Unicode UTF-8 Table]]
이 중 한글은 U+1100~U+11FF 사이에 한글 자모 영역, U+AC00~U+D7AF 사이의 한글 소리 마디 영역에 포함된다
//모든 공백 제거 String str =originalString.replaceAll("\\p{Z}", ""); // 앞뒤 공백만 제거(trim) String str = originalString.replaceAll("(^\\p{Z}+|\\p{Z}+$)", "");
StringBuilder b = new StringBuilder(); for (char c : input.toCharArray()) { if (c >= 128) b.append("\\u").append(String.format("%04X", (int) c)); else b.append(c); } return b.toString();