TextEncoder.Encode Method  
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
 
- Source:
 - TextEncoder.cs
 
Encodes the supplied string and returns the encoded text as a new string.
public:
 virtual System::String ^ Encode(System::String ^ value);
	public virtual string Encode(string value);
	abstract member Encode : string -> string
override this.Encode : string -> string
	Public Overridable Function Encode (value As String) As String
	Parameters
- value
 - String
 
The string to encode.
Returns
The encoded string.
Exceptions
value is null.
The TryEncodeUnicodeScalar(Int32, Char*, Int32, Int32) method failed. The encoder does not implement MaxOutputCharactersPerInputCharacter correctly.
Applies to
Encode(TextWriter, String)
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
Encodes the specified string to a TextWriter object.
public:
 void Encode(System::IO::TextWriter ^ output, System::String ^ value);
	public void Encode(System.IO.TextWriter output, string value);
	member this.Encode : System.IO.TextWriter * string -> unit
	Public Sub Encode (output As TextWriter, value As String)
	Parameters
- output
 - TextWriter
 
The stream to which to write the encoded text.
- value
 - String
 
The string to encode.
Applies to
Encode(TextWriter, Char[], Int32, Int32)
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
Encodes characters from an array and writes them to a TextWriter object.
public:
 virtual void Encode(System::IO::TextWriter ^ output, cli::array <char> ^ value, int startIndex, int characterCount);
	public virtual void Encode(System.IO.TextWriter output, char[] value, int startIndex, int characterCount);
	abstract member Encode : System.IO.TextWriter * char[] * int * int -> unit
override this.Encode : System.IO.TextWriter * char[] * int * int -> unit
	Public Overridable Sub Encode (output As TextWriter, value As Char(), startIndex As Integer, characterCount As Integer)
	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.
The TryEncodeUnicodeScalar(Int32, Char*, Int32, Int32) method failed. The encoder does not implement MaxOutputCharactersPerInputCharacter correctly.
value is null.
startIndex is out of range.
characterCount is out of range.
Applies to
Encode(TextWriter, String, Int32, Int32)
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
Encodes a substring and writes it to a TextWriter object.
public:
 virtual void Encode(System::IO::TextWriter ^ output, System::String ^ value, int startIndex, int characterCount);
	public virtual void Encode(System.IO.TextWriter output, string value, int startIndex, int characterCount);
	abstract member Encode : System.IO.TextWriter * string * int * int -> unit
override this.Encode : System.IO.TextWriter * string * int * int -> unit
	Public Overridable Sub Encode (output As TextWriter, value As String, startIndex As Integer, characterCount As Integer)
	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.
The TryEncodeUnicodeScalar(Int32, Char*, Int32, Int32) method failed. The encoder does not implement MaxOutputCharactersPerInputCharacter correctly.
value is null.
startIndex is out of range.
characterCount is out of range.
Applies to
Encode(ReadOnlySpan<Char>, Span<Char>, Int32, Int32, Boolean)
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
- Source:
 - TextEncoder.cs
 
Encodes the supplied characters.
public virtual System.Buffers.OperationStatus Encode(ReadOnlySpan<char> source, Span<char> destination, out int charsConsumed, out int charsWritten, bool isFinalBlock = true);
	abstract member Encode : ReadOnlySpan<char> * Span<char> * int * int * bool -> System.Buffers.OperationStatus
override this.Encode : ReadOnlySpan<char> * Span<char> * int * int * bool -> System.Buffers.OperationStatus
	Public Overridable Function Encode (source As ReadOnlySpan(Of Char), destination As Span(Of Char), ByRef charsConsumed As Integer, ByRef charsWritten As Integer, Optional isFinalBlock As Boolean = true) As OperationStatus
	Parameters
- source
 - ReadOnlySpan<Char>
 
A source buffer containing the characters to encode.
- 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.