private static boolean isInsideSurrogatePair(char[] text, int offset) {
    return offset > 0 && offset < text.length && Character.isHighSurrogate(text[offset - 1]) && Character.isLowSurrogate(text[offset]);
  }
private static boolean isInsideSurrogatePair(char[] text, int offset)