docs: private static int doUnescape(
        String s, int i, StringBuilder sb, ErrorReporter errorReporter, SourceLocation loc) {
      checkArgument(i < s.length(), "Found escape sequence at the end of a string.");
  
      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 'b':
          sb.append('\b');
          break;
        case 'f':
          sb.append('\f');
          break;
        case '\\':
        case '\"':
        case '\'':
        case '>':
          sb.append(c);
          break;
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
          --i; // backup to first octal digit
          int nOctalDigits = 1;
          int digitLimit = c < '4' ? 3 : 2;
          while (nOctalDigits < digitLimit
              && i + nOctalDigits < s.length()
              && isOctal(s.charAt(i + nOctalDigits))) {
            ++nOctalDigits;
          }
          sb.append((char) Integer.parseInt(s.substring(i, i + nOctalDigits), 8));
          i += nOctalDigits;
          break;
        case 'x':
        case 'u':
          String hexCode;
          int nHexDigits = (c == 'u' ? 4 : 2);
          try {
            hexCode = s.substring(i, i + nHexDigits);
          } catch (IndexOutOfBoundsException ioobe) {
            errorReporter.report(loc.offsetStartCol(i + 1), INVALID_UNICODE_SEQUENCE, s.substring(i));
            return i + nHexDigits;
          }
  
          int unicodeValue;
          try {
            unicodeValue = Integer.parseInt(hexCode, 16);
          } catch (NumberFormatException nfe) {
            errorReporter.report(loc.offsetStartCol(i + 1), INVALID_UNICODE_SEQUENCE, hexCode);
            return i + nHexDigits;
          }
  
          sb.append((char) unicodeValue);
          i += nHexDigits;
          break;
        default:
          errorReporter.report(loc.offsetStartCol(i), UNKNOWN_ESCAPE_CODE, c);
          return i;
      }
  
      return i;
    }