decodeUtf16be function
Produce a String from a sequence of UTF-16BE encoded bytes. This method
strips a leading BOM by default, but can be overridden by setting the
optional parameter stripBom
to false. Set the replacementCodepoint
to
null to throw an ArgumentError rather than replace the bad value.
The default value for the replacementCodepoint
is U+FFFD.
Implementation
String decodeUtf16be(List<int> bytes,
[int offset = 0,
int? length,
bool stripBom = true,
int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) {
var codeunits = (Utf16beBytesToCodeUnitsDecoder(
bytes, offset, length, stripBom, replacementCodepoint))
.decodeRest();
return String.fromCharCodes(
utf16CodeUnitsToCodepoints(codeunits, 0, null, replacementCodepoint)
.whereType<int>());
}