Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Text.​Encoder
Assembly: System.Runtime
Inheritance: object → Encoder
Converts a set of characters into a sequence of bytes.
Properties
public
EncoderFallback
Fallback
Gets or sets a <see cref="T:System.Text.EncoderFallback" /> object for the current <see cref="T:System.Text.Encoder" /> object.
public
EncoderFallbackBuffer
FallbackBuffer
Gets the <see cref="T:System.Text.EncoderFallbackBuffer" /> object associated with the current <see cref="T:System.Text.Encoder" /> object.
Methods
public
void
Convert​(Char* chars,
int charCount,
Byte* bytes,
int byteCount,
bool flush,
Int32& charsUsed,
Int32& bytesUsed,
Boolean& completed)
public
void
Convert​(char[] chars,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex,
int byteCount,
bool flush,
Int32& charsUsed,
Int32& bytesUsed,
Boolean& completed)
public
void
Convert​(ReadOnlySpan<​char> chars,
Span<​byte> bytes,
bool flush,
Int32& charsUsed,
Int32& bytesUsed,
Boolean& completed)
public
int
GetByteCount​(Char* chars,
int count,
bool flush)
When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters starting at the specified character pointer. A parameter indicates whether to clear the internal state of the encoder after the calculation.
Returns The number of bytes produced by encoding the specified characters and any characters in the internal buffer.
chars
A pointer to the first character to encode.
count
The number of characters to encode.
flush
<see langword="true" /> to simulate clearing the internal state of the encoder after the calculation; otherwise, <see langword="false" /> .
public
int
GetByteCount​(char[] chars,
int index,
int count,
bool flush)
When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters from the specified character array. A parameter indicates whether to clear the internal state of the encoder after the calculation.
Returns The number of bytes produced by encoding the specified characters and any characters in the internal buffer.
chars
The character array containing the set of characters to encode.
index
The index of the first character to encode.
count
The number of characters to encode.
flush
<see langword="true" /> to simulate clearing the internal state of the encoder after the calculation; otherwise, <see langword="false" /> .
public
int
GetByteCount​(ReadOnlySpan<​char> chars,
bool flush)
When overridden in a derived class, calculates the number of bytes produced by encoding a set of characters in the 'chars' span. A parameter indicates whether to clear the internal state of the encoder after the calculation.
Returns The number of bytes produced by encoding the specified characters and any characters in the internal buffer.
chars
A character span to encode.
flush
<see langword="true" /> to simulate clearing the internal state of the encoder after the calculation; otherwise, <see langword="false" /> .
public
int
GetBytes​(Char* chars,
int charCount,
Byte* bytes,
int byteCount,
bool flush)
When overridden in a derived class, encodes a set of characters starting at the specified character pointer and any characters in the internal buffer into a sequence of bytes that are stored starting at the specified byte pointer. A parameter indicates whether to clear the internal state of the encoder after the conversion.
Returns The actual number of bytes written at the location indicated by the <paramref name="bytes" /> parameter.
chars
A pointer to the first character to encode.
charCount
The number of characters to encode.
bytes
A pointer to the location at which to start writing the resulting sequence of bytes.
byteCount
The maximum number of bytes to write.
flush
<see langword="true" /> to clear the internal state of the encoder after the conversion; otherwise, <see langword="false" /> .
public
int
GetBytes​(char[] chars,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex,
bool flush)
When overridden in a derived class, encodes a set of characters from the specified character array and any characters in the internal buffer into the specified byte array. A parameter indicates whether to clear the internal state of the encoder after the conversion.
Returns The actual number of bytes written into <paramref name="bytes" /> .
chars
The character array containing the set of characters to encode.
charIndex
The index of the first character to encode.
charCount
The number of characters to encode.
bytes
The byte array to contain the resulting sequence of bytes.
byteIndex
The index at which to start writing the resulting sequence of bytes.
flush
<see langword="true" /> to clear the internal state of the encoder after the conversion; otherwise, <see langword="false" /> .
public
int
GetBytes​(ReadOnlySpan<​char> chars,
Span<​byte> bytes,
bool flush)
When overridden in a derived class, encodes a set of characters in the input characters span and any characters in the internal buffer into a sequence of bytes that are stored in the input byte span. A parameter indicates whether to clear the internal state of the encoder after the conversion.
Returns The actual number of bytes written at the location indicated by the <paramref name="bytes" /> parameter.
chars
A character span to encode.
bytes
A byte span to write the resulting sequence of bytes to.
flush
<see langword="true" /> to clear the internal state of the encoder after the conversion; otherwise, <see langword="false" /> .
public
void
Reset​()
When overridden in a derived class, sets the encoder back to its initial state.
public
bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj
The object to compare with the current object.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public
Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .
public
string
ToString​()
Inherited from object
Returns a string that represents the current object.
Returns A string that represents the current object.