Utf16BytesToCodeUnitsDecoder constructor
Utf16BytesToCodeUnitsDecoder(])
create Utf16BytesToCodeUnitsDecoder
Implementation
factory Utf16BytesToCodeUnitsDecoder(
List<int> utf16EncodedBytes, [
int offset = 0,
int? length,
int replacementCodepoint = unicodeReplacementCharacterCodepoint,
]) {
length ??= utf16EncodedBytes.length - offset;
if (hasUtf16BeBom(utf16EncodedBytes, offset, length)) {
return Utf16beBytesToCodeUnitsDecoder(utf16EncodedBytes, offset + 2,
length - 2, false, replacementCodepoint);
} else if (hasUtf16LeBom(utf16EncodedBytes, offset, length)) {
return Utf16leBytesToCodeUnitsDecoder(utf16EncodedBytes, offset + 2,
length - 2, false, replacementCodepoint);
} else {
return Utf16beBytesToCodeUnitsDecoder(
utf16EncodedBytes, offset, length, false, replacementCodepoint);
}
}