code: public static int findOffsetFromCodePoint(char source[], int start, int limit, int offset32) {
          char ch;
          int result = start, count = offset32;
          if (offset32 > limit - start) {
              throw new ArrayIndexOutOfBoundsException(offset32);
          }
          while (result < limit && count > 0) {
              ch = source[result];
              if (isLeadSurrogate(ch) && ((result + 1) < limit)
                      && isTrailSurrogate(source[result + 1])) {
                  result++;
              }
  
              count--;
              result++;
          }
          if (count != 0) {
              throw new ArrayIndexOutOfBoundsException(offset32);
          }
          return result - start;
      }
docs: Returns the UTF-16 offset that corresponds to a UTF-32 offset. Used for random access. See
  the {@link UTF16 class description} for notes on roundtripping.
  
  @param source The UTF-16 char array whose substring is to be analysed
  @param start Offset of the substring to be analysed
  @param limit Offset of the substring to be analysed
  @param offset32 UTF-32 offset relative to start
  @return UTF-16 offset relative to start
  @exception IndexOutOfBoundsException If offset32 is out of bounds.