TextEncoder.Encode Method

Definition

Overloads

Encode(String)

Encodes the supplied string and returns the encoded text as a new string.

Encode(TextWriter, String)

Encodes the specified string to a TextWriter object.

Encode(TextWriter, Char[], Int32, Int32)

Encodes characters from an array and writes them to a TextWriter object.

Encode(TextWriter, String, Int32, Int32)

Encodes a substring and writes it to a TextWriter object.

Encode(ReadOnlySpan<Char>, Span<Char>, Int32, Int32, Boolean)

Encodes the supplied characters.

Encode(String)

Source:
TextEncoder.cs
Source:
TextEncoder.cs
Source:
TextEncoder.cs
Source:
TextEncoder.cs

Encodes the supplied string and returns the encoded text as a new string.

C#
public virtual string Encode(string value);

Parameters

value
String

The string to encode.

Returns

The encoded string.

Exceptions

value is null.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Encode(TextWriter, String)

Source:
TextEncoder.cs
Source:
TextEncoder.cs
Source:
TextEncoder.cs
Source:
TextEncoder.cs

Encodes the specified string to a TextWriter object.

C#
public void Encode(System.IO.TextWriter output, string value);

Parameters

output
TextWriter

The stream to which to write the encoded text.

value
String

The string to encode.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Encode(TextWriter, Char[], Int32, Int32)

Source:
TextEncoder.cs
Source:
TextEncoder.cs
Source:
TextEncoder.cs
Source:
TextEncoder.cs

Encodes characters from an array and writes them to a TextWriter object.

C#
public virtual void Encode(System.IO.TextWriter output, char[] value, int startIndex, int characterCount);

Parameters

output
TextWriter

The stream to which to write the encoded text.

value
Char[]

The array of characters to encode.

startIndex
Int32

The array index of the first character to encode.

characterCount
Int32

The number of characters in the array to encode.

Exceptions

output is null.

value is null.

startIndex is out of range.

characterCount is out of range.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Encode(TextWriter, String, Int32, Int32)

Source:
TextEncoder.cs
Source:
TextEncoder.cs
Source:
TextEncoder.cs
Source:
TextEncoder.cs

Encodes a substring and writes it to a TextWriter object.

C#
public virtual void Encode(System.IO.TextWriter output, string value, int startIndex, int characterCount);

Parameters

output
TextWriter

The stream to which to write the encoded text.

value
String

The string whose substring is to be encoded.

startIndex
Int32

The index where the substring starts.

characterCount
Int32

The number of characters in the substring.

Exceptions

output is null.

value is null.

startIndex is out of range.

characterCount is out of range.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Encode(ReadOnlySpan<Char>, Span<Char>, Int32, Int32, Boolean)

Source:
TextEncoder.cs
Source:
TextEncoder.cs
Source:
TextEncoder.cs
Source:
TextEncoder.cs

Encodes the supplied characters.

C#
public virtual System.Buffers.OperationStatus Encode(ReadOnlySpan<char> source, Span<char> destination, out int charsConsumed, out int charsWritten, bool isFinalBlock = true);

Parameters

source
ReadOnlySpan<Char>

A source buffer containing the characters to encode.

destination
Span<Char>

The destination buffer to which the encoded form of source will be written.

charsConsumed
Int32

The number of characters consumed from the source buffer.

charsWritten
Int32

The number of characters written to the destination buffer.

isFinalBlock
Boolean

true to indicate there is no further source data that needs to be encoded; otherwise, false.

Returns

An enumeration value that describes the result of the encoding operation.

Remarks

The buffers source and destination must not overlap.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)