decode method

String decode(
  1. List<int> bytes, {
  2. ByteCodecType? forceType,
})

Implementation

String decode(List<int> bytes, {ByteCodecType? forceType}) {
  if (bytes.isEmpty) return '';
  final decodeType = forceType ?? codecType;
  if (decodeType == ByteCodecType.ISO_8859_1) {
    return latin1.decode(ByteUtil.trim(bytes), allowInvalid: true);
  } else if (decodeType == ByteCodecType.UTF16) {
    return _decodeWithUTF16(bytes);
  } else if (decodeType == ByteCodecType.UTF16BE) {
    return _decodeWithUTF16BE(bytes);
  } else if (decodeType == ByteCodecType.UTF8) {
    return utf8.decode(ByteUtil.trim(bytes), allowMalformed: true);
  } else if (decodeType == ByteCodecType.UTF16LE) {
    return _decodeWithUTF16LE(bytes);
  } else {
    return '';
  }
}