CxSmilesParser { static String unescape(String str) { int dst = 0; int src = 0; char[] chars = str.toCharArray(); int len = chars.length; while (src < chars.length) { if (src + 3 < len && chars[src] == '&' && chars[src+1] == '#' && isDigit(chars[src+2])) { int tmp = src+2; int code = 0; while (tmp < len && isDigit(chars[tmp])) { code *= 10; code += chars[tmp] - '0'; tmp++; } if (tmp < len && chars[tmp] == ';') { src = tmp+1; chars[dst++] = (char) code; continue; } } chars[dst++] = chars[src++]; } return new String(chars, 0, dst); } private  CxSmilesParser();   }
@Test public void unescape() { assertThat(CxSmilesParser.unescape("&#36;"), is("$")); assertThat(CxSmilesParser.unescape("&#127;"), is("\u007F")); assertThat(CxSmilesParser.unescape("&#9;"), is("\t")); }