decode static method
Implementation
static UDecodedText decode(Uint8List bytes, {String? forced}) {
if (bytes.isEmpty) return const UDecodedText("", "utf-8");
if (forced != null) return UDecodedText(_decodeAs(bytes, forced.toLowerCase(), _bomLength(bytes)), forced.toLowerCase());
final int bom = _bomLength(bytes);
if (bom > 0) {
final String name = _bomEncoding(bytes);
return UDecodedText(_decodeAs(bytes, name, bom), name);
}
if (_isValidUtf8(bytes)) return UDecodedText(utf8.decode(bytes, allowMalformed: true), "utf-8");
if (_looksArabic(bytes)) return UDecodedText(Cp1256.decode(bytes), "windows-1256");
return UDecodedText(latin1.decode(bytes, allowInvalid: true), "windows-1252");
}