graphemeWidth function

int graphemeWidth(
  1. String grapheme
)

Returns the physical terminal column width of grapheme (0, 1, or 2).

Implementation

int graphemeWidth(String grapheme) {
  if (grapheme.isEmpty) return 0;
  if (isZeroWidthGrapheme(grapheme)) return 0;
  if (isWideGrapheme(grapheme)) return 2;
  return 1;
}