AsciiDecoder class
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 read-only, inherited
- The hash code for this object.
- runtimeType → Type read-only, inherited
- A representation of the runtime type of the object.
Methods
- bind(
Stream< List< stream) → Stream<int> >String> inherited - Transforms the provided
stream. - cast<
RS, RT> () → Converter< RS, RT> inherited - Provides a
Converter<RS, RT>view of this stream transformer. - convert(
List< int> bytes, [int start = 0, int? end]) → Stringinherited - Converts the
bytes(a list of unsigned 7- or 8-bit integers) to the corresponding string. - fuse<
TT> (Converter< String, TT> other) → Converter<List< int> , TT>inherited - Fuses
thiswithother. - noSuchMethod(
Invocation invocation) → dynamic inherited - Invoked when a non-existent method or property is accessed.
- startChunkedConversion(
Sink< String> sink) → ByteConversionSink - Starts a chunked conversion.
- toString(
) → String inherited - A string representation of this object.
Operators
- operator ==(
Object other) → bool inherited - The equality operator.
© 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/AsciiDecoder-class.html