AsciiDecoder class final

Converts ASCII bytes to string.

Example:

const asciiDecoder = AsciiDecoder();
final asciiValues = [68, 97, 114, 116];
final result = asciiDecoder.convert(asciiValues);
print(result); // Dart

Throws a FormatException if bytes contains values that are not in the range 0 .. 127, and allowInvalid is false (the default).

If allowInvalid is true, any byte outside the range 0..127 is replaced by the Unicode replacement character, U+FFFD ('�').

Example with allowInvalid set to true:

const asciiDecoder = AsciiDecoder(allowInvalid: true);
final asciiValues = [68, 97, 114, 116, 20, 0xFF];
final result = asciiDecoder.convert(asciiValues);
print(result); // Dart �
print(result.codeUnits.last.toRadixString(16)); // fffd
Inheritance

Constructors

AsciiDecoder({bool allowInvalid = false})
const

Properties

hashCode int
The hash code for this object.
read-onlyinherited
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

bind(Stream<List<int>> stream) Stream<String>
Transforms the provided stream.
inherited
cast<RS, RT>() Converter<RS, RT>
Provides a Converter<RS, RT> view of this stream transformer.
inherited
convert(List<int> bytes, [int start = 0, int? end]) String
Converts the bytes (a list of unsigned 7- or 8-bit integers) to the corresponding string.
inherited
fuse<TT>(Converter<String, TT> other) Converter<List<int>, TT>
Fuses this with other.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startChunkedConversion(Sink<String> sink) ByteConversionSink
Starts a chunked conversion.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited