code: public static String substringByCodepoints(String s, OffsetRange<CharOffset> substringBounds) {
      return substringByCodepoints(s, substringBounds.startInclusive().asInt(),
          // +1 because called method takes exclusive end offset like String#substring
          substringBounds.endInclusive().asInt() + 1 );
    }
docs: Returns the substring of {@code s} indicated by {@code substringBounds}, where the character
  offsets are interpreted as Unicode code point offsets.  You should typically use this instead
  of {@link String#substring(int)} because the latter will fail badly in the presence of
  non-BMP characters.
  
  Beware this takes linear time according to the end index of the substring, rather than the
  substring's length, like for {@link String#substring(int)}