private static int getCharEndIndex(@NotNull String line, int i) {
    if (i >= line.length()) return -1;
    char c = line.charAt(i++);
    if (c == '\\') {
      // like \uFFFD
      char c1 = line.charAt(i++);
      if (c1 == 'u') {
        while (i < line.length() && line.charAt(i) == 'u') i++;
        i += 4;
      } else if (c1 >= '0' && c1 <= '7') { // octal escape
        char c2 = i < line.length() ? line.charAt(i) : 0;
        if (c2 >= '0' && c2 <= '7') {
          i++;
          char c3 = i < line.length() ? line.charAt(i) : 0;
          if (c3 >= '0' && c3 <= '7' && c1 <= '3') {
            i++;
          }
        }
      }
    }
    return i;
  }
private static int getCharEndIndex(@NotNull String line, int i)