src/com/google/javascript/jscomp/parsing/parser/Scanner.java
/**
   * Converts unicode escapes in the given string to the equivalent unicode character. If there are
   * no escapes, returns the input unchanged. If there is an invalid escape sequence, returns null.
   */
Converts unicode escapes in the given string to the equivalent unicode character. If there are
no escapes, returns the input unchanged. If there is an invalid escape sequence, returns null.
Converts unicode escapes in the given string to the equivalent unicode character . If there are no escapes returns the input unchanged . If there is an invalid escape sequence returns null .
private static String processUnicodeEscapes(String value) {
    while (value.contains("\\")) {
      int escapeStart = value.indexOf('\\');
      try {
        if (value.charAt(escapeStart + 1) != 'u') {
          return null;
        }
        String hexDigits;
        int escapeEnd;
        if (value.charAt(escapeStart + 2) != '{') {
          escapeEnd = escapeStart + 6;
          hexDigits = value.substring(escapeStart + 2, escapeEnd);
        } else {
          escapeEnd = escapeStart + 3;
          while (Character.digit(value.charAt(escapeEnd), 0x10) >= 0) {
            escapeEnd++;
          }
          if (value.charAt(escapeEnd) != '}') {
            return null;
          }
          hexDigits = value.substring(escapeStart + 3, escapeEnd);
          escapeEnd++;
        }
        char ch = (char) Integer.parseInt(hexDigits, 0x10);
        if (!isIdentifierPart(ch)) {
          return null;
        }
        value = value.substring(0, escapeStart) + ch + value.substring(escapeEnd);
      } catch (NumberFormatException | StringIndexOutOfBoundsException e) {
        return null;
      }
    }
    return value;
  }
private static String processUnicodeEscapes ( String value ) { while ( value . contains ( "\\" ) ) { int escapeStart = value . indexOf ( '\\' ) ; try { if ( value . charAt ( escapeStart + 1 ) != 'u' ) { return null ; } String hexDigits ; int escapeEnd ; if ( value . charAt ( escapeStart + 2 ) != '{' ) { escapeEnd = escapeStart + 6 ; hexDigits = value . substring ( escapeStart + 2 , escapeEnd ) ; } else { escapeEnd = escapeStart + 3 ; while ( Character . digit ( value . charAt ( escapeEnd ) , 0x10 ) >= 0 ) { escapeEnd ++ ; } if ( value . charAt ( escapeEnd ) != '}' ) { return null ; } hexDigits = value . substring ( escapeStart + 3 , escapeEnd ) ; escapeEnd ++ ; } char ch = ( char ) Integer . parseInt ( hexDigits , 0x10 ) ; if ( ! isIdentifierPart ( ch ) ) { return null ; } value = value . substring ( 0 , escapeStart ) + ch + value . substring ( escapeEnd ) ; } catch ( NumberFormatException | StringIndexOutOfBoundsException e ) { return null ; } } return value ; }
Converts unicode escapes in the given string to the equivalent unicode character.
Converts unicode escapes in the given string to the equivalent unicode character .
// Simple escape with exactly four hex digits: \\uXXXX // Escape with braces can have any number of hex digits: \\u{XXXXXXX} // TODO(mattloring): Allow code points greater than the size of a char