internal static int CodePointCountImpl(char[] a, int offset, int count)
{
int endIndex = offset + count;
int n = 0;
for (int i = offset; i < endIndex;)
{
n++;
if (char.IsHighSurrogate(a[i++]))
{
if (i < endIndex && char.IsLowSurrogate(a[i]))
{
i++;
}
}
}
return n;
}