implement grapheme_substr

but it's not optimized and needs to DRY out.
grapheme_rindex: substr → grapheme_substr

Replace substr with grapheme_substr in grapheme_rindex.  This incovered a bug in
grapheme_substr when the length argument is longer than the length of the
string, which has been fixed.