code: public static int offsetByCodePoints(char[] text, int start, int count, int index,
              int codePointOffset) {
          int limit = start + count;
          if (start < 0 || limit < start || limit > text.length || index < start || index > limit) {
              throw new IndexOutOfBoundsException("index ( " + index +
                      ") out of range " + start +
                      ", " + limit +
                      " in array 0, " + text.length);
          }
  
          if (codePointOffset < 0) {
              while (++codePointOffset <= 0) {
                  char ch = text[--index];
                  if (index < start) {
                      throw new IndexOutOfBoundsException("index ( " + index +
                              ") < start (" + start +
                              ")");
                  }
                  while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && index > start) {
                      ch = text[--index];
                      if (ch < MIN_HIGH_SURROGATE || ch > MAX_HIGH_SURROGATE) {
                          if (++codePointOffset > 0) {
                              return index+1;
                          }
                      }
                  }
              }
          } else {
              while (--codePointOffset >= 0) {
                  char ch = text[index++];
                  if (index > limit) {
                      throw new IndexOutOfBoundsException("index ( " + index +
                              ") > limit (" + limit +
                              ")");
                  }
                  while (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE && index < limit) {
                      ch = text[index++];
                      if (ch < MIN_LOW_SURROGATE || ch > MAX_LOW_SURROGATE) {
                          if (--codePointOffset < 0) {
                              return index-1;
                          }
                      }
                  }
              }
          }
  
          return index;
      }
docs: Equivalent to the
  {@link Character#offsetByCodePoints(char[], int, int, int, int)}
  method, for convenience.  Adjusts the char index by a code point offset.
  @param text the characters to check
  @param start the start of the range to check
  @param count the length of the range to check
  @param index the index to adjust
  @param codePointOffset the number of code points by which to offset the index
  @return the adjusted index