code: public static int bounds(String source, int offset16) {
          char ch = source.charAt(offset16);
          if (isSurrogate(ch)) {
              if (isLeadSurrogate(ch)) {
                  if (++offset16 < source.length() && isTrailSurrogate(source.charAt(offset16))) {
                      return LEAD_SURROGATE_BOUNDARY;
                  }
              } else {
                  // isTrailSurrogate(ch), so
                  --offset16;
                  if (offset16 >= 0 && isLeadSurrogate(source.charAt(offset16))) {
                      return TRAIL_SURROGATE_BOUNDARY;
                  }
              }
          }
          return SINGLE_CHAR_BOUNDARY;
      }
docs: Returns the type of the boundaries around the char at offset16. Used for random access.
  
  @param source Text to analyse
  @param offset16 UTF-16 offset
  @return
  <ul>
  <li> SINGLE_CHAR_BOUNDARY : a single char; the bounds are [offset16, offset16+1]
  <li> LEAD_SURROGATE_BOUNDARY : a surrogate pair starting at offset16; the bounds
  are [offset16, offset16 + 2]
  <li> TRAIL_SURROGATE_BOUNDARY : a surrogate pair starting at offset16 - 1; the
  bounds are [offset16 - 1, offset16 + 1]
  </ul>
  For bit-twiddlers, the return values for these are chosen so that the boundaries
  can be gotten by: [offset16 - (value &gt;&gt; 2), offset16 + (value &amp; 3)].
  @exception IndexOutOfBoundsException If offset16 is out of bounds.