private static int javaScriptUnescapeHelper(String s,int i,StringBuilder sb){
  if (i >= s.length()) {
    throw new IllegalArgumentException("End-of-string after escape character in [" + s + "]");
  }
  char c=s.charAt(i++);
switch (c) {
case 'n':
    sb.append('\n');
  break;
case 'r':
sb.append('\r');
break;
case 't':
sb.append('\t');
break;
case '\\':
case '\"':
case '\'':
case '>':
sb.append(c);
break;
case 'u':
String hexCode;
try {
hexCode=s.substring(i,i + 4);
}
 catch (IndexOutOfBoundsException ioobe) {
throw new IllegalArgumentException("Invalid unicode sequence [" + s.substring(i) + "] at index "+ i+ " in ["+ s+ "]");
}
int unicodeValue;
try {
unicodeValue=Integer.parseInt(hexCode,16);
}
 catch (NumberFormatException nfe) {
throw new IllegalArgumentException("Invalid unicode sequence [" + hexCode + "] at index "+ i+ " in ["+ s+ "]");
}
sb.append((char)unicodeValue);
i+=4;
break;
default :
throw new IllegalArgumentException("Unknown escape code [" + c + "] at index "+ i+ " in ["+ s+ "]");
}
return i;
}

private static int javaScriptUnescapeHelper ( String s , int i , StringBuilder sb ) { if ( i >= s . length ( ) ) { throw new IllegalArgumentException ( "End-of-string after escape character in [" + s + "]" ) ; } char c = s . charAt ( i ++ ) ; switch ( c ) { case 'n' : sb . append ( '\n' ) ; break ; case 'r' : sb . append ( '\r' ) ; break ; case 't' : sb . append ( '\t' ) ; break ; case '\\' : case '\"' : case '\'' : case '>' : sb . append ( c ) ; break ; case 'u' : String hexCode ; try { hexCode = s . substring ( i , i + 4 ) ; } catch ( IndexOutOfBoundsException ioobe ) { throw new IllegalArgumentException ( "Invalid unicode sequence [" + s . substring ( i ) + "] at index " + i + " in [" + s + "]" ) ; } int unicodeValue ; try { unicodeValue = Integer . parseInt ( hexCode , 16 ) ; } catch ( NumberFormatException nfe ) { throw new IllegalArgumentException ( "Invalid unicode sequence [" + hexCode + "] at index " + i + " in [" + s + "]" ) ; } sb . append ( ( char ) unicodeValue ) ; i += 4 ; break ; default : throw new IllegalArgumentException ( "Unknown escape code [" + c + "] at index " + i + " in [" + s + "]" ) ; } return i ; }
looks for an escape code starting at index i of s , and appends it to sb .
