본문 바로가기

아는 만큼 보인다/Tip

문자열 속 일부 유니코드 치환


// 문자열 속 일부 유니코드 치환

public void replaceUnicodeNotation(String input) {

while( true ) {

Matcher m = Pattern.compile("\\\\u([\\da-fA-F]{4})").matcher(input);

if(!m.find()) break;


char ch = (char) Integer.parseInt(m.group(1), 16);

String a = String.valueOf( ch );

input = m.replaceFirst( Matcher.quoteReplacement(a) );

}

return input;

}

'아는 만큼 보인다 > Tip' 카테고리의 다른 글

enum 자료형 흉내내기  (0) 2015.01.15
Java HotSpot VM Options 몇 가지  (0) 2014.12.18
Java 메모리 누수(memory leak)  (0) 2014.12.16
Java Memory Model  (0) 2014.11.20
eclipse에서 java compiler 변경시.. 에러  (0) 2013.01.08