code: public static int charAt(char source[], int start, int limit, int offset16) {
          offset16 += start;
          if (offset16 < start || offset16 >= limit) {
              throw new ArrayIndexOutOfBoundsException(offset16);
          }
  
          char single = source[offset16];
          if (!isSurrogate(single)) {
              return single;
          }
  
          // Convert the UTF-16 surrogate pair if necessary.
          // For simplicity in usage, and because the frequency of pairs is
          // low, look both directions.
          if (single <= LEAD_SURROGATE_MAX_VALUE) {
              offset16++;
              if (offset16 >= limit) {
                  return single;
              }
              char trail = source[offset16];
              if (isTrailSurrogate(trail)) {
                  return Character.toCodePoint(single, trail);
              }
          } else { // isTrailSurrogate(single), so
              if (offset16 == start) {
                  return single;
              }
              offset16--;
              char lead = source[offset16];
              if (isLeadSurrogate(lead))
                  return Character.toCodePoint(lead, single);
          }
          return single; // return unmatched surrogate
      }
docs: Extract a single UTF-32 value from a substring. Used when iterating forwards or backwards
  (with <code>UTF16.getCharCount()</code>, as well as random access. If a validity check is
  required, use <code><a href="../lang/UCharacter.html#isLegal(char)">UCharacter.isLegal()
  </a></code>
  on the return value. If the char retrieved is part of a surrogate pair, its supplementary
  character will be returned. If a complete supplementary character is not found the incomplete
  character will be returned
  
  @param source Array of UTF-16 chars
  @param start Offset to substring in the source array for analyzing
  @param limit Offset to substring in the source array for analyzing
  @param offset16 UTF-16 offset relative to start
  @return UTF-32 value for the UTF-32 value that contains the char at offset16. The boundaries
  of that codepoint are the same as in <code>bounds32()</code>.
  @exception IndexOutOfBoundsException Thrown if offset16 is not within the range of start and limit.