decode method

  1. @override
String decode(
  1. List<int> utf16EncodedBytes, [
  2. int offset = 0,
  3. int? length
])
override

Implementation

@override
String decode(List<int> utf16EncodedBytes, [int offset = 0, int? length]) {
  if (Utf16Decoder.hasUtf16beBom(utf16EncodedBytes, offset, length)) {
    offset = offset + 2;
  }

  length ??= utf16EncodedBytes.length - offset;

  var sublist = utf16EncodedBytes.sublist(offset, offset + length);
  sublist = _switchCharacters(sublist);

  var utf16CodeUnits = Uint8List.fromList(sublist).buffer.asUint16List();
  return String.fromCharCodes(utf16CodeUnits);
}