getChar32 static method
Implementation
@preferInline
static int getChar32(ParseState state, int pos) {
var ch = state.ch;
final source = state.source;
if (ch >= 0xD800 && ch <= 0xDBFF) {
if (pos + 1 < source.length) {
final ch2 = source.codeUnitAt(pos + 1);
if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) {
ch = ((ch - 0xD800) << 10) + (ch2 - 0xDC00) + 0x10000;
} else {
throw FormatException('Unpaired high surrogate', source, pos);
}
} else {
throw FormatException('The source has been exhausted', source, pos);
}
} else {
if (ch >= 0xDC00 && ch <= 0xDFFF) {
throw FormatException(
'UTF-16 surrogate values are illegal in UTF-32', source, pos);
}
}
return state.ch = ch;
}