src/main/java/org/mvel2/util/ParseTools.java
public static int handleEscapeSequence(char[] escapeStr, int pos) {
    escapeStr[pos - 1] = 0;

    switch (escapeStr[pos]) {
      case '\\':
        escapeStr[pos] = '\\';
        return 1;
      case 'b':
        escapeStr[pos] = '\b';
        return 1;
      case 'f':
        escapeStr[pos] = '\f';
        return 1;
      case 't':
        escapeStr[pos] = '\t';
        return 1;
      case 'r':
        escapeStr[pos] = '\r';
        return 1;
      case 'n':
        escapeStr[pos] = '\n';
        return 1;
      case '\'':
        escapeStr[pos] = '\'';
        return 1;
      case '"':
        escapeStr[pos] = '\"';
        return 1;
      case 'u':
        //unicode
        int s = pos;
        if (s + 4 > escapeStr.length)
          throw new CompileException("illegal unicode escape sequence", escapeStr, pos);
        else {
          while (++pos - s != 5) {
            if ((escapeStr[pos] > ('0' - 1) && escapeStr[pos] < ('9' + 1)) ||
                (escapeStr[pos] > ('A' - 1) && escapeStr[pos] < ('F' + 1))) {
            }
            else {
              throw new CompileException("illegal unicode escape sequence", escapeStr, pos);
            }
          }

          escapeStr[s - 1] = (char) Integer.decode("0x" + new String(escapeStr, s + 1, 4)).intValue();
          escapeStr[s] = 0;
          escapeStr[s + 1] = 0;
          escapeStr[s + 2] = 0;
          escapeStr[s + 3] = 0;
          escapeStr[s + 4] = 0;

          return 5;
        }

      default:
        //octal
        s = pos;
        while (escapeStr[pos] >= '0' && escapeStr[pos] < '8') {
          if (pos != s && escapeStr[s] > '3') {
            escapeStr[s - 1] = (char) Integer.decode("0" + new String(escapeStr, s, pos - s + 1)).intValue();
            escapeStr[s] = 0;
            escapeStr[s + 1] = 0;
            return 2;
          }
          else if ((pos - s) == 2) {
            escapeStr[s - 1] = (char) Integer.decode("0" + new String(escapeStr, s, pos - s + 1)).intValue();
            escapeStr[s] = 0;
            escapeStr[s + 1] = 0;
            escapeStr[s + 2] = 0;
            return 3;
          }

          if (pos + 1 == escapeStr.length || (escapeStr[pos] < '0' || escapeStr[pos] > '7')) {
            escapeStr[s - 1] = (char) Integer.decode("0" + new String(escapeStr, s, pos - s + 1)).intValue();
            escapeStr[s] = 0;
            return 1;
          }

          pos++;
        }
        throw new CompileException("illegal escape sequence: " + escapeStr[pos], escapeStr, pos);
    }
  }
/**
   * Replace escape sequences and return trim required.
   *
   * @param escapeStr -
   * @param pos       -
   * @return -
   */
Replace escape sequences and return trim required.
@param escapeStr
@param pos
@return
Replace escape sequences and return trim required . @param escapeStr @param pos @return
public static int handleEscapeSequence(char[] escapeStr, int pos) {
    escapeStr[pos - 1] = 0;
    switch (escapeStr[pos]) {
      case '\\':
        escapeStr[pos] = '\\';
        return 1;
      case 'b':
        escapeStr[pos] = '\b';
        return 1;
      case 'f':
        escapeStr[pos] = '\f';
        return 1;
      case 't':
        escapeStr[pos] = '\t';
        return 1;
      case 'r':
        escapeStr[pos] = '\r';
        return 1;
      case 'n':
        escapeStr[pos] = '\n';
        return 1;
      case '\'':
        escapeStr[pos] = '\'';
        return 1;
      case '"':
        escapeStr[pos] = '\"';
        return 1;
      case 'u':
        int s = pos;
        if (s + 4 > escapeStr.length)
          throw new CompileException("illegal unicode escape sequence", escapeStr, pos);
        else {
          while (++pos - s != 5) {
            if ((escapeStr[pos] > ('0' - 1) && escapeStr[pos] < ('9' + 1)) ||
                (escapeStr[pos] > ('A' - 1) && escapeStr[pos] < ('F' + 1))) {
            }
            else {
              throw new CompileException("illegal unicode escape sequence", escapeStr, pos);
            }
          }
          escapeStr[s - 1] = (char) Integer.decode("0x" + new String(escapeStr, s + 1, 4)).intValue();
          escapeStr[s] = 0;
          escapeStr[s + 1] = 0;
          escapeStr[s + 2] = 0;
          escapeStr[s + 3] = 0;
          escapeStr[s + 4] = 0;
          return 5;
        }
      default:
        s = pos;
        while (escapeStr[pos] >= '0' && escapeStr[pos] < '8') {
          if (pos != s && escapeStr[s] > '3') {
            escapeStr[s - 1] = (char) Integer.decode("0" + new String(escapeStr, s, pos - s + 1)).intValue();
            escapeStr[s] = 0;
            escapeStr[s + 1] = 0;
            return 2;
          }
          else if ((pos - s) == 2) {
            escapeStr[s - 1] = (char) Integer.decode("0" + new String(escapeStr, s, pos - s + 1)).intValue();
            escapeStr[s] = 0;
            escapeStr[s + 1] = 0;
            escapeStr[s + 2] = 0;
            return 3;
          }
          if (pos + 1 == escapeStr.length || (escapeStr[pos] < '0' || escapeStr[pos] > '7')) {
            escapeStr[s - 1] = (char) Integer.decode("0" + new String(escapeStr, s, pos - s + 1)).intValue();
            escapeStr[s] = 0;
            return 1;
          }
          pos++;
        }
        throw new CompileException("illegal escape sequence: " + escapeStr[pos], escapeStr, pos);
    }
  }
public static int handleEscapeSequence ( char [ ] escapeStr , int pos ) { escapeStr [ pos - 1 ] = 0 ; switch ( escapeStr [ pos ] ) { case '\\' : escapeStr [ pos ] = '\\' ; return 1 ; case 'b' : escapeStr [ pos ] = '\b' ; return 1 ; case 'f' : escapeStr [ pos ] = '\f' ; return 1 ; case 't' : escapeStr [ pos ] = '\t' ; return 1 ; case 'r' : escapeStr [ pos ] = '\r' ; return 1 ; case 'n' : escapeStr [ pos ] = '\n' ; return 1 ; case '\'' : escapeStr [ pos ] = '\'' ; return 1 ; case '"' : escapeStr [ pos ] = '\"' ; return 1 ; case 'u' : int s = pos ; if ( s + 4 > escapeStr . length ) throw new CompileException ( "illegal unicode escape sequence" , escapeStr , pos ) ; else { while ( ++ pos - s != 5 ) { if ( ( escapeStr [ pos ] > ( '0' - 1 ) && escapeStr [ pos ] < ( '9' + 1 ) ) || ( escapeStr [ pos ] > ( 'A' - 1 ) && escapeStr [ pos ] < ( 'F' + 1 ) ) ) { } else { throw new CompileException ( "illegal unicode escape sequence" , escapeStr , pos ) ; } } escapeStr [ s - 1 ] = ( char ) Integer . decode ( "0x" + new String ( escapeStr , s + 1 , 4 ) ) . intValue ( ) ; escapeStr [ s ] = 0 ; escapeStr [ s + 1 ] = 0 ; escapeStr [ s + 2 ] = 0 ; escapeStr [ s + 3 ] = 0 ; escapeStr [ s + 4 ] = 0 ; return 5 ; } default : s = pos ; while ( escapeStr [ pos ] >= '0' && escapeStr [ pos ] < '8' ) { if ( pos != s && escapeStr [ s ] > '3' ) { escapeStr [ s - 1 ] = ( char ) Integer . decode ( "0" + new String ( escapeStr , s , pos - s + 1 ) ) . intValue ( ) ; escapeStr [ s ] = 0 ; escapeStr [ s + 1 ] = 0 ; return 2 ; } else if ( ( pos - s ) == 2 ) { escapeStr [ s - 1 ] = ( char ) Integer . decode ( "0" + new String ( escapeStr , s , pos - s + 1 ) ) . intValue ( ) ; escapeStr [ s ] = 0 ; escapeStr [ s + 1 ] = 0 ; escapeStr [ s + 2 ] = 0 ; return 3 ; } if ( pos + 1 == escapeStr . length || ( escapeStr [ pos ] < '0' || escapeStr [ pos ] > '7' ) ) { escapeStr [ s - 1 ] = ( char ) Integer . decode ( "0" + new String ( escapeStr , s , pos - s + 1 ) ) . intValue ( ) ; escapeStr [ s ] = 0 ; return 1 ; } pos ++ ; } throw new CompileException ( "illegal escape sequence: " + escapeStr [ pos ] , escapeStr , pos ) ; } }
Replace escape sequences and return trim required.
Replace escape sequences and return trim required .
//unicode //octal