EncodingExtensions.Convert Method

Definition

Overloads

Convert(Decoder, ReadOnlySequence<Byte>, IBufferWriter<Char>, Boolean, Int64, Boolean)

Converts a ReadOnlySequence<T> to UTF-16 encoded characters and writes the result to writer.

Convert(Decoder, ReadOnlySpan<Byte>, IBufferWriter<Char>, Boolean, Int64, Boolean)

Converts a ReadOnlySpan<T> to chars using decoder and writes the result to writer.

Convert(Encoder, ReadOnlySequence<Char>, IBufferWriter<Byte>, Boolean, Int64, Boolean)

Converts a ReadOnlySequence<T> to encoded bytes and writes the result to writer.

Convert(Encoder, ReadOnlySpan<Char>, IBufferWriter<Byte>, Boolean, Int64, Boolean)

Converts a ReadOnlySpan<T> to bytes using encoder and writes the result to writer.

Convert(Decoder, ReadOnlySequence<Byte>, IBufferWriter<Char>, Boolean, Int64, Boolean)

Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs

Converts a ReadOnlySequence<T> to UTF-16 encoded characters and writes the result to writer.

C#
public static void Convert(this System.Text.Decoder decoder, in System.Buffers.ReadOnlySequence<byte> bytes, System.Buffers.IBufferWriter<char> writer, bool flush, out long charsUsed, out bool completed);

Parameters

decoder
Decoder

The decoder instance that can convert bytes to char values.

bytes
ReadOnlySequence<Byte>

A sequence of bytes to decode.

writer
IBufferWriter<Char>

The buffer to which the decoded characters will be written.

flush
Boolean

true to indicate no further data is to be converted; otherwise false.

charsUsed
Int64

When this method returns, contains the count of characters that were written to writer.

completed
Boolean

When this method returns, contains true if decoder contains no partial internal state; otherwise, false. If flush is true, this will always be set to true when the method returns.

Exceptions

bytes contains data that cannot be decoded and decoder is configured to throw when such data is seen.

Applies to

.NET 10 and other versions
Product Versions
.NET 5, 6, 7, 8, 9, 10

Convert(Decoder, ReadOnlySpan<Byte>, IBufferWriter<Char>, Boolean, Int64, Boolean)

Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs

Converts a ReadOnlySpan<T> to chars using decoder and writes the result to writer.

C#
public static void Convert(this System.Text.Decoder decoder, ReadOnlySpan<byte> bytes, System.Buffers.IBufferWriter<char> writer, bool flush, out long charsUsed, out bool completed);

Parameters

decoder
Decoder

The decoder instance that can convert bytes to char values.

bytes
ReadOnlySpan<Byte>

A sequence of bytes to decode.

writer
IBufferWriter<Char>

The buffer to which the decoded chars will be written.

flush
Boolean

true to indicate no further data is to be converted; otherwise false.

charsUsed
Int64

When this method returns, contains the count of chars which were written to writer.

completed
Boolean

When this method returns, contains true if decoder contains no partial internal state; otherwise, false. If flush is true, this will always be set to true when the method returns.

Exceptions

bytes contains data that cannot be encoded and decoder is configured to throw when such data is seen.

Applies to

.NET 10 and other versions
Product Versions
.NET 5, 6, 7, 8, 9, 10

Convert(Encoder, ReadOnlySequence<Char>, IBufferWriter<Byte>, Boolean, Int64, Boolean)

Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs

Converts a ReadOnlySequence<T> to encoded bytes and writes the result to writer.

C#
public static void Convert(this System.Text.Encoder encoder, in System.Buffers.ReadOnlySequence<char> chars, System.Buffers.IBufferWriter<byte> writer, bool flush, out long bytesUsed, out bool completed);

Parameters

encoder
Encoder

The encoder instance that can convert char values to bytes.

chars
ReadOnlySequence<Char>

A sequence of characters to encode.

writer
IBufferWriter<Byte>

The buffer to which the encoded bytes will be written.

flush
Boolean

true to indicate no further data is to be converted; otherwise false.

bytesUsed
Int64

When this method returns, contains the count of bytes which were written to writer.

completed
Boolean

When this method returns, contains true if all input up until bytesUsed was converted; otherwise, false. If flush is true, this will always be set to true when the method returns.

Exceptions

chars contains data that cannot be encoded and encoder is configured to throw when such data is seen.

Applies to

.NET 10 and other versions
Product Versions
.NET 5, 6, 7, 8, 9, 10

Convert(Encoder, ReadOnlySpan<Char>, IBufferWriter<Byte>, Boolean, Int64, Boolean)

Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs
Source:
EncodingExtensions.cs

Converts a ReadOnlySpan<T> to bytes using encoder and writes the result to writer.

C#
public static void Convert(this System.Text.Encoder encoder, ReadOnlySpan<char> chars, System.Buffers.IBufferWriter<byte> writer, bool flush, out long bytesUsed, out bool completed);

Parameters

encoder
Encoder

The encoder instance that can convert char values to bytes.

chars
ReadOnlySpan<Char>

A sequence of characters to encode.

writer
IBufferWriter<Byte>

The buffer to which the encoded bytes will be written.

flush
Boolean

true to indicate no further data is to be converted; otherwise false.

bytesUsed
Int64

When this method returns, contains the count of bytes which were written to writer.

completed
Boolean

When this method returns, contains true if encoder contains no partial internal state; otherwise, false. If flush is true, this will always be set to true when the method returns.

Exceptions

chars contains data that cannot be encoded and encoder is configured to throw when such data is seen.

Applies to

.NET 10 and other versions
Product Versions
.NET 5, 6, 7, 8, 9, 10