public static String unescape(final String string)
{
int u = string.indexOf("\\u");
if (u < 0) return string;
StrBuilder result = new StrBuilder();
int lastCopied = 0;
for (;;)
{
result.append(string.substring(lastCopied, u));
/* we don't worry about an exception here,
* because the lexer checked that string is correct */
char c = (char) Integer.parseInt(string.substring(u + 2, u + 6), 16);
result.append(c);
lastCopied = u + 6;
u = string.indexOf("\\u", lastCopied);
if (u < 0)
{
result.append(string.substring(lastCopied));
return result.toString();
}
}
}