code: public static int offsetByCodePoints(CharSequence text, int index, int codePointOffset) {
          if (index < 0 || index > text.length()) {
              throw new IndexOutOfBoundsException("index ( " + index +
                      ") out of range 0, " + text.length());
          }
  
          if (codePointOffset < 0) {
              while (++codePointOffset <= 0) {
                  char ch = text.charAt(--index);
                  while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && index > 0) {
                      ch = text.charAt(--index);
                      if (ch < MIN_HIGH_SURROGATE || ch > MAX_HIGH_SURROGATE) {
                          if (++codePointOffset > 0) {
                              return index+1;
                          }
                      }
                  }
              }
          } else {
              int limit = text.length();
              while (--codePointOffset >= 0) {
                  char ch = text.charAt(index++);
                  while (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE && index < limit) {
                      ch = text.charAt(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(CharSequence, int, int)}
  method, for convenience.  Adjusts the char index by a code point offset.
  @param text the characters 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