String (String text) { if (text == null) return null; Matcher matcher = UNICODE_CHAR.matcher(text); if (!matcher.find()) return text; // fast path matcher.reset(); int lastEnd = 0; StringBuilder sb = new StringBuilder(text.length()); while (matcher.find()) { sb.append(text, lastEnd, matcher.start()); char c = (char)Integer.parseInt(matcher.group().substring(2), 16); sb.append(c); lastEnd = matcher.end(); } sb.append(text.substring(lastEnd)); return sb.toString(); }