int (@NotNull String s, int index, @NotNull Predicate<? super Character> charPredicate) { // \uFFFD needs at least 6 positions if (index - 5 < 0) return -1; int start = findSlashU(s, index - 4); if (start < 0) return -1; try { int code = Integer.parseInt(s.substring(index - 3, index + 1), 16); if (!charPredicate.test((char) code)) return -1; } catch (NumberFormatException e) { return -1; } return start; }