====== Unicode ====== * [[programming:문자|문자]] 먼저 읽을 것. * [[http://www.utf8-chartable.de/unicode-utf8-table.pl|Unicode UTF-8 Table]] ===== Encoding 방식의 차이는? ===== * [[https://javarevisited.blogspot.com/2015/02/difference-between-utf-8-utf-16-and-utf.html|Difference between UTF-8, UTF-16 and UTF-32 Character Encoding? Example]] * ''utf-8'', ''utf-16'', ''utf-32''는 **Character Encoding**이다. * ''utf-16''과 ''utf-32''는 인코딩이 Unicode code point 와 일치해보이지만 ''utf-8''은 전혀 다르다. ==== UTF-8 ==== * 가변 길이(variable length) encoding * 최소 1byte * Unicode code point 0-127 은 1개의 바이트로 표현함. * 128 이상의 code point 는 2~4byte 로 표현함. * ASCII와 호환됨. ASCII를 표현할 때 1byte만 필요함. * 즉, 영문만 있을 때는 ASCII와 UTF-8 이 동일하게 표현된다. ASCII가 워낙 광범위하게 쓰였기 때문에 UTF-8이 따라감. ==== UTF-16 ==== * 가변 길이 encoding * 2byte 혹은 4byte 로 표현함. * ASCII와 호환 안됨. ==== UTF-32 ==== * 고정 길이(fixed width) 인코딩 * 4byte 고정 길이 ===== 한글 ===== * ''이 중 한글은 U+1100~U+11FF 사이에 한글 자모 영역, U+AC00~U+D7AF 사이의 한글 소리 마디 영역에 포함된다'' * [[http://ko.wikipedia.org/wiki/%EC%9C%A0%EB%8B%88%EC%BD%94%EB%93%9C_%EB%B2%94%EC%9C%84_%EB%AA%A9%EB%A1%9D|유니코드 범위 목록]] ===== IDEOGRAPHIC SPACE ===== * [[http://www.yunsobi.com/blog/596|replaceAll(" ","") trim() 으로 제거되지 않는 공백 제거]] //모든 공백 제거 String str =originalString.replaceAll("\\p{Z}", ""); // 앞뒤 공백만 제거(trim) String str = originalString.replaceAll("(^\\p{Z}+|\\p{Z}+$)", ""); * [[http://www.fileformat.info/info/unicode/char/3000/index.htm|Unicode Character 'IDEOGRAPHIC SPACE' (U+3000)]] ===== Unicode To ASCII Escape ===== * [[http://www.rapidmonkey.com/unicodeconverter/|Web Unicode Converter]] * [[http://stackoverflow.com/questions/6230190/convert-international-string-to-u-codes-in-java|unicode - Convert International String to \u Codes in java - Stack Overflow]] 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(); ===== 참조 ===== * [[https://pat.im/1183|표준이 된 세벌식? - (3) 유니코드를 통한 요즘한글 부호계 표준화 작업]] * [[http://helloworld.naver.com/helloworld/19187|hello world » 한글 인코딩의 이해 1편: 한글 인코딩의 역사와 유니코드]] * [[http://helloworld.naver.com/helloworld/76650|hello world » 한글 인코딩의 이해 2편: 유니코드와 Java를 이용한 한글 처리]]