isZeroWidthGrapheme function
Returns true if the grapheme cluster represents a zero-width character (non-spacing marks, format controls, zero-width spaces, or soft hyphens).
Implementation
bool isZeroWidthGrapheme(String grapheme) {
final len = grapheme.length;
if (len == 0) return true;
var i = 0;
while (i < len) {
var cp = grapheme.codeUnitAt(i++);
if (cp >= 0xD800 && cp <= 0xDBFF && i < len) {
final lo = grapheme.codeUnitAt(i);
if (lo >= 0xDC00 && lo <= 0xDFFF) {
cp = 0x10000 + ((cp & 0x3FF) << 10) + (lo & 0x3FF);
i++;
}
}
if (!isZeroWidthCodePoint(cp)) return false;
}
return true;
}