scalarToUtf16Offset static method
Implementation
static int scalarToUtf16Offset(String text, int scalarOffset) {
int utf16 = 0;
int scalar = 0;
for (final rune in text.runes) {
if (scalar >= scalarOffset) break;
utf16 += rune > 0xFFFF ? 2 : 1;
scalar++;
}
return utf16;
}