This class converts UTF-8 code units (lists of unsigned 8-bit integers) to a string.
Example:
final utf8Decoder = utf8.decoder; const encodedBytes = [ 195, 142, 195, 177, 197, 163, 195, 169, 114, 195, 177, 195, 165, 197, 163, 195, 174, 195, 182, 195, 177, 195, 165, 196, 188, 195, 174, 197, 190, 195, 165, 197, 163, 195, 174, 225, 187, 157, 195, 177]; final decodedBytes = utf8Decoder.convert(encodedBytes); print(decodedBytes); // Îñţérñåţîöñåļîžåţîờñ
Throws a FormatException if the encoded input contains invalid UTF-8 byte sequences and allowMalformed is false (the default).
If allowMalformed is true, invalid byte sequences are converted into one or more Unicode replacement characters, U+FFFD ('�').
Example with allowMalformed set to true:
const utf8Decoder = Utf8Decoder(allowMalformed: true); const encodedBytes = [0xFF]; final decodedBytes = utf8Decoder.convert(encodedBytes); print(decodedBytes); // �
stream. Converter<RS, RT> view of this stream transformer. codeUnits (a list of unsigned 8-bit integers) to the corresponding string. this with other.
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-convert/Utf8Decoder-class.html