dart.convert


Top-Level Variables
ASCII: dynamic
HTML_ESCAPE: dynamic
JSON: dynamic
LATIN1: dynamic
UNICODE_REPLACEMENT_CHARACTER_RUNE: dynamic
UTF8: dynamic
Classes
AsciiCodec
AsciiDecoder
AsciiEncoder
ByteConversionSink
ByteConversionSinkBase
ChunkedConversionSink
ClosableStringSink
Codec
Converter
Encoding
HtmlEscape
HtmlEscapeMode
JsonCodec
JsonCyclicError
JsonDecoder
JsonEncoder
JsonUnsupportedObjectError
Latin1Codec
Latin1Decoder
Latin1Encoder
LineSplitter
StringConversionSink
StringConversionSinkBase
StringConversionSinkMixin
Utf8Codec
Utf8Decoder
Utf8Encoder

Converters for JSON and UTF-8, as well as support for creating additional converters.

Top-Level Variables

static const dynamic ASCII

An instance of the default implementation of the AsciiCodec.

This instance provides a convenient access to the most common ASCII use cases.

Examples:

var encoded = ASCII.encode("This is ASCII!");
var decoded = ASCII.decode([0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73,
                            0x20, 0x41, 0x53, 0x43, 0x49, 0x49, 0x21]);

static const dynamic HTML_ESCAPE
static const dynamic JSON

An instance of the default implementation of the JsonCodec.

This instance provides a convenient access to the most common JSON use cases.

Examples:

var encoded = JSON.encode([1, 2, { "a": null }]);
var decoded = JSON.decode('["foo", { "bar": 499 }]');

static const dynamic LATIN1

An instance of the default implementation of the Latin1Codec.

This instance provides a convenient access to the most common ISO Latin 1 use cases.

Examples:

var encoded = LATIN1.encode("blåbærgrød");
var decoded = LATIN1.decode([0x62, 0x6c, 0xe5, 0x62, 0xe6,
                             0x72, 0x67, 0x72, 0xf8, 0x64]);

static const dynamic UNICODE_REPLACEMENT_CHARACTER_RUNE = 65533

The Unicode Replacement character U+FFFD (�).

static const dynamic UTF8

An instance of the default implementation of the Utf8Codec.

This instance provides a convenient access to the most common UTF-8 use cases.

Examples:

var encoded = UTF8.encode("Îñţérñåţîöñåļîžåţîờñ");
var decoded = UTF8.decode([0x62, 0x6c, 0xc3, 0xa5, 0x62, 0xc3, 0xa6,
                           0x72, 0x67, 0x72, 0xc3, 0xb8, 0x64]);


Class AsciiCodec extends Encoding

Fields
decoder: Converter
encoder: Converter
name: String
Getters and Setters
decoder: Converter<List<int>, String>
encoder: Converter<String, List<int>>
name: String
Constructors
AsciiCodec(bool allowInvalid)
Methods
decode(List<int> bytes, bool allowInvalid): String

An AsciiCodec allows encoding strings as ASCII bytes and decoding ASCII bytes to strings.

Fields

final Converter decoder
final Converter encoder
final String name

Getters and Setters

Converter<List<int>, String> get decoder
Converter<String, List<int>> get encoder
String get name

Constructors

AsciiCodec(bool allowInvalid)

Instantiates a new AsciiCodec.

If allowInvalid is true, the decode method and the converter returned by decoder will default to allowing invalid values. If allowing invalid values, the values will be decoded into the Unicode Replacement character (U+FFFD). If not, an exception will be thrown. Calls to the decode method can choose to override this default.

Encoders will not accept invalid (non Latin-1) characters.

Methods

String decode(List<int> bytes, bool allowInvalid)

Decodes the ASCII bytes (a list of unsigned 7-bit integers) to the corresponding string.

If bytes contains values that are not in the range 0 .. 127, the decoder will eventually throw a FormatException.

If allowInvalid is not provided, it defaults to the value used to create this AsciiCodec.


Class AsciiDecoder extends _UnicodeSubsetDecoder

Constructors
AsciiDecoder(bool allowInvalid)
Methods
startChunkedConversion(ChunkedConversionSink<String> sink): ByteConversionSink

Constructors

AsciiDecoder(bool allowInvalid)

Methods

ByteConversionSink startChunkedConversion(ChunkedConversionSink<String> sink)

Starts a chunked conversion.

The converter works more efficiently if the given sink is a StringConversionSink.


Class AsciiEncoder extends _UnicodeSubsetEncoder

Constructors
AsciiEncoder()

This class converts strings of only ASCII characters to bytes.

Constructors

AsciiEncoder()

Abstract class ByteConversionSink extends ChunkedConversionSink<List<int>>

Constructors
ByteConversionSink()
ByteConversionSink.from(ChunkedConversionSink<List<int>> sink)
ByteConversionSink.withCallback( callback)
Methods
addSlice(List<int> chunk, int start, int end, bool isLast): void

The ByteConversionSink provides an interface for converters to efficiently transmit byte data.

Instead of limiting the interface to one non-chunked list of bytes it accepts its input in chunks (themselves being lists of bytes).

Constructors

ByteConversionSink()
factory ByteConversionSink.from(ChunkedConversionSink<List<int>> sink)
factory ByteConversionSink.withCallback( callback)

Methods

void addSlice(List<int> chunk, int start, int end, bool isLast)

Adds the next chunk to this.

Adds the bytes defined by start and end-exclusive to this.

If isLast is true closes this.

Contrary to add the given chunk must not be held onto. Once the method returns, it is safe to overwrite the data in it.


Abstract class ByteConversionSinkBase extends ByteConversionSink

Constructors
ByteConversionSinkBase()
Methods
add(List<int> chunk): void
addSlice(List<int> chunk, int start, int end, bool isLast): void
close(): void

This class provides a base-class for converters that need to accept byte inputs.

Constructors

ByteConversionSinkBase()

Methods

void add(List<int> chunk)

Adds chunked data to this sink.

This method is also used when converters are used as StreamTransformers.

void addSlice(List<int> chunk, int start, int end, bool isLast)

Adds the next chunk to this.

Adds the bytes defined by start and end-exclusive to this.

If isLast is true closes this.

Contrary to add the given chunk must not be held onto. Once the method returns, it is safe to overwrite the data in it.

void close()

Closes the sink.

This signals the end of the chunked conversion. This method is called when converters are used as StreamTransformer's.


Abstract class ChunkedConversionSink

Constructors
ChunkedConversionSink()
ChunkedConversionSink.withCallback(<T> callback)
Methods
add(T chunk): void
close(): void

A ChunkedConversionSink is used to transmit data more efficiently between two converters during chunked conversions.

Constructors

ChunkedConversionSink()
factory ChunkedConversionSink.withCallback(<T> callback)

Methods

void add(T chunk)

Adds chunked data to this sink.

This method is also used when converters are used as StreamTransformers.

void close()

Closes the sink.

This signals the end of the chunked conversion. This method is called when converters are used as StreamTransformer's.


Abstract class ClosableStringSink extends StringSink

Constructors
ClosableStringSink.fromStringSink(StringSink sink, onClose)
Methods
close(): void

A ClosableStringSink extends the StringSink interface by adding a close method.

Constructors

factory ClosableStringSink.fromStringSink(StringSink sink, onClose)

Creates a new instance combining a StringSink sink and a callback onClose which is invoked when the returned instance is closed.

Methods

void close()

Closes this and flushes any outstanding data.


Abstract class Codec

Fields
decoder: Converter
encoder: Converter
inverted: Codec
Getters and Setters
decoder: Converter<T, S>
encoder: Converter<S, T>
inverted: Codec<T, S>
Constructors
Codec()
Methods
decode(T encoded): S
encode(S input): T
fuse(Codec<T, dynamic> other): Codec<S, dynamic>

A Codec encodes and (if supported) decodes data.

Codecs can be fused. For example fusing JSON and UTF8 produces an encoder that can convert Json objects directly to bytes, or can decode bytes directly to json objects.

Fused codecs generally attempt to optimize the operations and can be faster than executing each step of an encoding separately.

Codecs are still experimental and are subject to change without notice.

Fields

final Converter decoder
final Converter encoder
final Codec inverted

Getters and Setters

Converter<T, S> get decoder

Returns the decoder of this, converting from T to S.

It may be stateful an should not be reused.

Converter<S, T> get encoder

Returns the encoder from S to T.

It may be stateful and should not be reused.

Codec<T, S> get inverted

Inverts this.

The encoder and decoder of the resulting codec are swapped.

Constructors

Codec()

Methods

S decode(T encoded)
T encode(S input)
Codec<S, dynamic> fuse(Codec<T, dynamic> other)

Fuses this with other.

When encoding, the resulting codec encodes with this before encoding with other.

When decoding, the resulting codec decodes with other before decoding with this.

In some cases one needs to use the inverted codecs to be able to fuse them correctly. That is, the output type of this (T) must match the input type of the second codec other.

Examples:

final JSON_TO_BYTES = JSON.fuse(UTF8);
List<int> bytes = JSON_TO_BYTES.encode(["json-object"]);
var decoded = JSON_TO_BYTES.decode(bytes);
assert(decoded is List && decoded[0] == "json-object");

var inverted = JSON.inverted;
var jsonIdentity = JSON.fuse(inverted);
var jsonObject = jsonIdentity.encode(["1", 2]);
assert(jsonObject is List && jsonObject[0] == "1" && jsonObject[1] == 2);


Abstract class Converter implements StreamTransformer<dynamic, dynamic>

Constructors
Converter()
Methods
bind(Stream<dynamic> source): Stream<dynamic>
convert(S input): T
fuse(Converter<T, dynamic> other): Converter<S, dynamic>
startChunkedConversion(ChunkedConversionSink<dynamic> sink): ChunkedConversionSink<dynamic>

A Converter converts data from one representation into another.

Converters are still experimental and are subject to change without notice.

Constructors

Converter()

Methods

Stream<dynamic> bind(Stream<dynamic> source)
T convert(S input)

Converts input and returns the result of the conversion.

Converter<S, dynamic> fuse(Converter<T, dynamic> other)

Fuses this with other.

Encoding with the resulting converter is equivalent to converting with this before converting with other.

ChunkedConversionSink<dynamic> startChunkedConversion(ChunkedConversionSink<dynamic> sink)

Starts a chunked conversion.


Abstract class Encoding extends Codec<String, List<int>>

Fields
name: String
Getters and Setters
name: String
Constructors
Encoding()
Methods
decodeStream(Stream<List<int>> byteStream): Future<String>
getByName(String name): Encoding

Open-ended Encoding enum.

Fields

final String name

Getters and Setters

String get name

Name of the encoding.

If the encoding is standardized, this is the lower-case version of one of the IANA official names for the character set (see http://www.iana.org/assignments/character-sets/character-sets.xml)

Constructors

Encoding()

Methods

Future<String> decodeStream(Stream<List<int>> byteStream)
static Encoding getByName(String name)

Gets an Encoding object from the name of the character set name. The names used are the IANA official names for the character set (see http://www.iana.org/assignments/character-sets/character-sets.xml).

The name passed is case insensitive.

If character set is not supported null is returned.


Class HtmlEscape extends Converter<String, String>

Fields
mode: HtmlEscapeMode
Constructors
HtmlEscape(HtmlEscapeMode mode)
Methods
convert(String text): String
startChunkedConversion(ChunkedConversionSink<String> sink): StringConversionSink

Fields

final HtmlEscapeMode mode

Constructors

HtmlEscape(HtmlEscapeMode mode)

Methods

String convert(String text)

Converts input and returns the result of the conversion.

StringConversionSink startChunkedConversion(ChunkedConversionSink<String> sink)

Starts a chunked conversion.


Class HtmlEscapeMode

Static Fields
ATTRIBUTE: HtmlEscapeMode
ELEMENT: HtmlEscapeMode
UNKNOWN: HtmlEscapeMode
Fields
escapeApos: bool
escapeLtGt: bool
escapeQuot: bool
Methods
toString(): String

Static Fields

static const HtmlEscapeMode ATTRIBUTE
static const HtmlEscapeMode ELEMENT
static const HtmlEscapeMode UNKNOWN

Fields

final bool escapeApos
final bool escapeLtGt
final bool escapeQuot

Methods

String toString()

Returns a string representation of this object.


Class JsonCodec extends Codec<Object, String>

Fields
decoder: JsonDecoder
encoder: JsonEncoder
Getters and Setters
decoder: JsonDecoder
encoder: JsonEncoder
Constructors
JsonCodec()
JsonCodec.withReviver( reviver)
Methods
decode(String str, reviver): Object

A JsonCodec encodes JSON objects to strings and decodes strings to JSON objects.

Fields

final JsonDecoder decoder
final JsonEncoder encoder

Getters and Setters

JsonDecoder get decoder
JsonEncoder get encoder

Constructors

JsonCodec()
factory JsonCodec.withReviver( reviver)

Creates a JsonCodec with the given reviver.

The reviver function is called once for each object or list property that has been parsed during decoding. The key argument is either the integer list index for a list property, the map string for object properties, or null for the final result.

Methods

Object decode(String str, reviver)

Parses the string and returns the resulting Json object.

The optional reviver function is called once for each object or list property that has been parsed during decoding. The key argument is either the integer list index for a list property, the map string for object properties, or null for the final result.

The default reviver (when not provided) is the identity function.


Class JsonCyclicError extends JsonUnsupportedObjectError

Constructors
JsonCyclicError(Object object)
Methods
toString(): String

Reports that an object could not be stringified due to cyclic references.

An object that references itself cannot be serialized by stringify. When the cycle is detected, a JsonCyclicError is thrown.

Constructors

JsonCyclicError(Object object)

The first object that was detected as part of a cycle.

Methods

String toString()

Returns a string representation of this object.


Class JsonDecoder extends Converter<String, Object>

Constructors
JsonDecoder( reviver)
Methods
bind(Stream<String> stream): Stream<Object>
convert(String input): Object
startChunkedConversion(ChunkedConversionSink<Object> sink): StringConversionSink

This class parses JSON strings and builds the corresponding objects.

Constructors

JsonDecoder( reviver)

Constructs a new JsonDecoder.

The reviver may be null.

Methods

Stream<Object> bind(Stream<String> stream)
Object convert(String input)

Converts the given JSON-string input to its corresponding object.

Parsed JSON values are of the types num, String, bool, Null, Lists of parsed JSON values or Maps from String to parsed JSON values.

If this was initialized with a reviver, then the parsing operation invokes the reviver on every object or list property that has been parsed. The arguments are the property name (String) or list index (int), and the value is the parsed value. The return value of the reviver is used as the value of that property instead the parsed value.

Throws FormatException if the input is not valid JSON text.

StringConversionSink startChunkedConversion(ChunkedConversionSink<Object> sink)

Starts a conversion from a chunked JSON string to its corresponding object.

The output sink receives exactly one decoded element through add.


Class JsonEncoder extends Converter<Object, String>

Constructors
JsonEncoder()
Methods
bind(Stream<Object> stream): Stream<String>
convert(Object o): String
startChunkedConversion(ChunkedConversionSink<String> sink): ChunkedConversionSink<Object>

This class converts JSON objects to strings.

Constructors

JsonEncoder()

Methods

Stream<String> bind(Stream<Object> stream)
String convert(Object o)

Converts the given object o to its JSON representation.

Directly serializable values are num, String, bool, and Null, as well as some List and Map values. For List, the elements must all be serializable. For Map, the keys must be String and the values must be serializable.

If a value is any other type is attempted serialized, a "toJson()" method is invoked on the object and the result, which must be a directly serializable value, is serialized instead of the original value.

If the object does not support this method, throws, or returns a value that is not directly serializable, a JsonUnsupportedObjectError exception is thrown. If the call throws (including the case where there is no nullary "toJson" method, the error is caught and stored in the JsonUnsupportedObjectError's cause field.

If a List or Map contains a reference to itself, directly or through other lists or maps, it cannot be serialized and a JsonCyclicError is thrown.

Json Objects should not change during serialization. If an object is serialized more than once, stringify is allowed to cache the JSON text for it. I.e., if an object changes after it is first serialized, the new values may or may not be reflected in the result.

ChunkedConversionSink<Object> startChunkedConversion(ChunkedConversionSink<String> sink)

Starts a chunked conversion.

The converter works more efficiently if the given sink is a StringConversionSink.

Returns a chunked-conversion sink that accepts at most one object. It is an error to invoke add more than once on the returned sink.


Class JsonUnsupportedObjectError extends Error

Fields
cause: dynamic
unsupportedObject: dynamic
Constructors
JsonUnsupportedObjectError(dynamic unsupportedObject, dynamic cause)
Methods
toString(): String

Error thrown by JSON serialization if an object cannot be serialized.

The unsupportedObject field holds that object that failed to be serialized.

If an object isn't directly serializable, the serializer calls the 'toJson' method on the object. If that call fails, the error will be stored in the cause field. If the call returns an object that isn't directly serializable, the cause is be null.

Fields

final dynamic cause

The exception thrown by object's toJson method, if any.

final dynamic unsupportedObject

The object that could not be serialized.

Constructors

JsonUnsupportedObjectError(dynamic unsupportedObject, dynamic cause)

Methods

String toString()

Returns a string representation of this object.


Class Latin1Codec extends Encoding

Fields
decoder: Converter
encoder: Converter
name: String
Getters and Setters
decoder: Converter<List<int>, String>
encoder: Converter<String, List<int>>
name: String
Constructors
Latin1Codec(bool allowInvalid)
Methods
decode(List<int> bytes, bool allowInvalid): String

A LatinCodec encodes strings to ISO Latin-1 (aka ISO-8859-1) bytes and decodes Latin-1 bytes to strings.

Fields

final Converter decoder
final Converter encoder
final String name

Getters and Setters

Converter<List<int>, String> get decoder
Converter<String, List<int>> get encoder
String get name

Constructors

Latin1Codec(bool allowInvalid)

Instantiates a new Latin1Codec.

If allowInvalid is true, the decode method and the converter returned by decoder will default to allowing invalid values. Invalid values are decoded into the Unicode Replacement character (U+FFFD). Calls to the decode method can override this default.

Encoders will not accept invalid (non Latin-1) characters.

Methods

String decode(List<int> bytes, bool allowInvalid)

Decodes the Latin-1 bytes (a list of unsigned 8-bit integers) to the corresponding string.

If bytes contains values that are not in the range 0 .. 255, the decoder will eventually throw a FormatException.

If allowInvalid is not provided, it defaults to the value used to create this Latin1Codec.


Class Latin1Decoder extends _UnicodeSubsetDecoder

Constructors
Latin1Decoder(bool allowInvalid)
Methods
startChunkedConversion(ChunkedConversionSink<String> sink): ByteConversionSink

This class converts Latin-1 bytes (lists of unsigned 8-bit integers) to a string.

Constructors

Latin1Decoder(bool allowInvalid)

Instantiates a new Latin1Decoder.

The optional allowInvalid argument defines how convert deals with invalid bytes.

If it is true, convert replaces invalid bytes with the Unicode Replacement character U+FFFD (�). Otherwise it throws a FormatException.

Methods

ByteConversionSink startChunkedConversion(ChunkedConversionSink<String> sink)

Starts a chunked conversion.

The converter works more efficiently if the given sink is a StringConversionSink.


Class Latin1Encoder extends _UnicodeSubsetEncoder

Constructors
Latin1Encoder()

This class converts strings of only ISO Latin-1 characters to bytes.

Constructors

Latin1Encoder()

Class LineSplitter extends Converter<String, List<String>>

Constructors
LineSplitter()
Methods
convert(String data): List<String>
startChunkedConversion(ChunkedConversionSink<String> sink): StringConversionSink

This class splits String values into individual lines.

Constructors

LineSplitter()

Methods

List<String> convert(String data)

Converts input and returns the result of the conversion.

StringConversionSink startChunkedConversion(ChunkedConversionSink<String> sink)

Starts a chunked conversion.


Abstract class StringConversionSink extends ChunkedConversionSink<String>

Constructors
StringConversionSink()
StringConversionSink.from(ChunkedConversionSink<String> sink)
StringConversionSink.fromStringSink(StringSink sink)
StringConversionSink.withCallback( callback)
Methods
addSlice(String chunk, int start, int end, bool isLast): void
asStringSink(): ClosableStringSink
asUtf8Sink(bool allowMalformed): ByteConversionSink

This class provides an interface for converters to efficiently transmit String data.

Instead of limiting the interface to one non-chunked String it accepts partial strings or can be transformed into a byte sink that accepts UTF-8 code units.

Constructors

StringConversionSink()
factory StringConversionSink.from(ChunkedConversionSink<String> sink)
factory StringConversionSink.fromStringSink(StringSink sink)

Creates a new instance wrapping the given sink.

Every string that is added to the returned instance is forwarded to the sink. The instance is allowed to buffer and is not required to forward immediately.

factory StringConversionSink.withCallback( callback)

Methods

void addSlice(String chunk, int start, int end, bool isLast)

Adds the next chunk to this.

Adds the substring defined by start and end-exclusive to this.

If isLast is true closes this.

ClosableStringSink asStringSink()

Returns this as a ClosableStringSink.

If used, this method must be the first and only call to this. It invalidates this. All further operations must be performed on the result.

ByteConversionSink asUtf8Sink(bool allowMalformed)

Returns this as a sink that accepts UTF-8 input.

If used, this method must be the first and only call to this. It invalidates this. All further operations must be performed on the result.


Abstract class StringConversionSinkBase extends StringConversionSinkMixin

Constructors
StringConversionSinkBase()

This class provides a base-class for converters that need to accept String inputs.

Constructors

StringConversionSinkBase()

Abstract class StringConversionSinkMixin implements StringConversionSink

Constructors
StringConversionSinkMixin()
Methods
add(String str): void
addSlice(String str, int start, int end, bool isLast): void
asStringSink(): ClosableStringSink
asUtf8Sink(bool allowMalformed): ByteConversionSink
close(): void

This class provides a mixin for converters that need to accept String inputs.

Constructors

StringConversionSinkMixin()

Methods

void add(String str)

Adds chunked data to this sink.

This method is also used when converters are used as StreamTransformers.

void addSlice(String str, int start, int end, bool isLast)

Adds the next chunk to this.

Adds the substring defined by start and end-exclusive to this.

If isLast is true closes this.

ClosableStringSink asStringSink()

Returns this as a ClosableStringSink.

If used, this method must be the first and only call to this. It invalidates this. All further operations must be performed on the result.

ByteConversionSink asUtf8Sink(bool allowMalformed)

Returns this as a sink that accepts UTF-8 input.

If used, this method must be the first and only call to this. It invalidates this. All further operations must be performed on the result.

void close()

Closes the sink.

This signals the end of the chunked conversion. This method is called when converters are used as StreamTransformer's.


Class Utf8Codec extends Encoding

Fields
decoder: Converter
encoder: Converter
name: String
Getters and Setters
decoder: Converter<List<int>, String>
encoder: Converter<String, List<int>>
name: String
Constructors
Utf8Codec(bool allowMalformed)
Methods
decode(List<int> codeUnits, bool allowMalformed): String

A Utf8Codec encodes strings to utf-8 code units (bytes) and decodes UTF-8 code units to strings.

Fields

final Converter decoder
final Converter encoder
final String name

Getters and Setters

Converter<List<int>, String> get decoder
Converter<String, List<int>> get encoder
String get name

Constructors

Utf8Codec(bool allowMalformed)

Instantiates a new Utf8Codec.

The optional allowMalformed argument defines how decoder (and decode) deal with invalid or unterminated character sequences.

If it is true (and not overriden at the method invocation) decode and the decoder replace invalid (or unterminated) octet sequences with the Unicode Replacement character U+FFFD (�). Otherwise they throw a FormatException.

Methods

String decode(List<int> codeUnits, bool allowMalformed)

Decodes the UTF-8 codeUnits (a list of unsigned 8-bit integers) to the corresponding string.

If allowMalformed is true the decoder replaces invalid (or unterminated) character sequences with the Unicode Replacement character U+FFFD (�). Otherwise it throws a FormatException.

If allowMalformed is not given, it defaults to the allowMalformed that was used to instantiate this.


Class Utf8Decoder extends Converter<List<int>, String>

Constructors
Utf8Decoder(bool allowMalformed)
Methods
bind(Stream<List<int>> stream): Stream<String>
convert(List<int> codeUnits): String
startChunkedConversion(ChunkedConversionSink<String> sink): ByteConversionSink

This class converts UTF-8 code units (lists of unsigned 8-bit integers) to a string.

Constructors

Utf8Decoder(bool allowMalformed)

Instantiates a new Utf8Decoder.

The optional allowMalformed argument defines how convert deals with invalid or unterminated character sequences.

If it is true convert replaces invalid (or unterminated) character sequences with the Unicode Replacement character U+FFFD (�). Otherwise it throws a FormatException.

Methods

Stream<String> bind(Stream<List<int>> stream)
String convert(List<int> codeUnits)

Converts the UTF-8 codeUnits (a list of unsigned 8-bit integers) to the corresponding string.

ByteConversionSink startChunkedConversion(ChunkedConversionSink<String> sink)

Starts a chunked conversion.

The converter works more efficiently if the given sink is a StringConversionSink.


Class Utf8Encoder extends Converter<String, List<int>>

Constructors
Utf8Encoder()
Methods
bind(Stream<String> stream): Stream<List<int>>
convert(String string): List<int>
startChunkedConversion(ChunkedConversionSink<List<int>> sink): StringConversionSink

This class converts strings to their UTF-8 code units (a list of unsigned 8-bit integers).

Constructors

Utf8Encoder()

Methods

Stream<List<int>> bind(Stream<String> stream)
List<int> convert(String string)

Converts string to its UTF-8 code units (a list of unsigned 8-bit integers).

StringConversionSink startChunkedConversion(ChunkedConversionSink<List<int>> sink)

Starts a chunked conversion.

The converter works more efficiently if the given sink is a ByteConversionSink.