code: public static int moveCodePointOffset(String source, int offset16, int shift32) {
          int result = offset16;
          int size = source.length();
          int count;
          char ch;
          if (offset16 < 0 || offset16 > size) {
              throw new StringIndexOutOfBoundsException(offset16);
          }
          if (shift32 > 0) {
              if (shift32 + offset16 > size) {
                  throw new StringIndexOutOfBoundsException(offset16);
              }
              count = shift32;
              while (result < size && count > 0) {
                  ch = source.charAt(result);
                  if (isLeadSurrogate(ch) && ((result + 1) < size)
                          && isTrailSurrogate(source.charAt(result + 1))) {
                      result++;
                  }
                  count--;
                  result++;
              }
          } else {
              if (offset16 + shift32 < 0) {
                  throw new StringIndexOutOfBoundsException(offset16);
              }
              for (count = -shift32; count > 0; count--) {
                  result--;
                  if (result < 0) {
                      break;
                  }
                  ch = source.charAt(result);
                  if (isTrailSurrogate(ch) && result > 0
                          && isLeadSurrogate(source.charAt(result - 1))) {
                      result--;
                  }
              }
          }
          if (count != 0) {
              throw new StringIndexOutOfBoundsException(shift32);
          }
          return result;
      }
docs: Shifts offset16 by the argument number of codepoints
  
  @param source string
  @param offset16 UTF16 position to shift
  @param shift32 number of codepoints to shift
  @return new shifted offset16
  @exception IndexOutOfBoundsException if the new offset16 is out of bounds.