codePointAt function

int codePointAt(
  1. String text,
  2. int i
)

The code point that starts at i, or -1 at the end.

Implementation

int codePointAt(String text, int i) {
  if (i >= text.length) {
    return -1;
  }
  final high = text.codeUnitAt(i);
  if (high >= 0xD800 && high <= 0xDBFF && i + 1 < text.length) {
    final low = text.codeUnitAt(i + 1);
    if (low >= 0xDC00 && low <= 0xDFFF) {
      return 0x10000 + ((high - 0xD800) << 10) + (low - 0xDC00);
    }
  }
  return high;
}