countGraphemes method

int countGraphemes(
  1. String str
)

countGraphemes returns the number of grapheme clusters there are in the given string

Implementation

int countGraphemes(String str) {
  int count = 0;
  int index = 0;
  int brk;
  while ((brk = this.nextBreak(str, index)) < str.length) {
    index = brk;
    count++;
  }
  if (index < str.length) {
    count++;
  }
  return count;
}