나는 다음과 같은 내용의 텍스트가 (물론 코드를 참조하십시오유니 코드 서로 게이트 문자를 이스케이프?
는 내가 뭘 할 노력하고있어 유 뒤쪽으로가 문자 \ 두 가지로)이 이모티콘 (전화 아이콘을 탈출 자사의 원래 전화 아이콘? 아래의 첫 번째 메서드는 잘 작동하지만 본질적으로 범위를 벗어나서이 같은 문자를 이스케이프 처리 할 수 있습니다. 아래 첫 번째 메서드를 사용하여이 방법을 사용하는 방법을 알 수 없습니다.
어떻게 할 수 있습니까? 이 범위 기반의 이스케이프는 StringEscapeUtils와 동일한 출력으로 UnicodeEscaper를 사용합니다 (즉, \ uxx \ uxx로 이스케이프 한 다음 다시 전화 아이콘으로 이스케이프 취소).
import org.apache.commons.lang3.text.translate.UnicodeEscaper;
import org.apache.commons.lang3.text.translate.UnicodeUnescaper;
String text = "Unicode surrogate here-> <--here";
// escape the entire string...not what I want because there could
// be \n \r or any other escape chars that I want left in tact (i just want a range)
String text2 = org.apache.commons.lang.StringEscapeUtils.escapeJava(text);
System.out.println(text2); // "Unicode surrogate here-> \uD83D\uDCF1<--here"
// unescape it back to the phone emoticon
text2 = org.apache.commons.lang.StringEscapeUtils.unescapeJava(text);
System.out.println(text2); // "Unicode surrogate here-> <--here"
// How do I do the same as above but but looking for a range of chars to escape (i.e. any unicode surrogate)
// , which is what i want and not to escape the entire string
text2 = UnicodeEscaper.between(0x10000, 0x10FFFF).translate(text);
System.out.println(text2); // "Unicode surrogate here-> \u1F4F1<--here"
// unescape .... (need the phone emoticon here)
text2 = (new UnicodeUnescaper().translate(text2));
System.out.println(text2);// "Unicode surrogate here-> 1<--here"
'UnicodeEscaper'란 무엇입니까? – fge