mscorlib(4.0.0.0) API with additions
System.Text.Encoder Class Referenceabstract

Converts a set of characters into a sequence of bytes. More...

Inherited by System.Text.EncoderNLS.

Public Member Functions

virtual void Reset ()
 When overridden in a derived class, sets the encoder back to its initial state. More...
 
abstract 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. More...
 
virtual unsafe 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. More...
 
abstract 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. More...
 
virtual unsafe 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. More...
 
virtual void Convert (char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, int byteCount, bool flush, out int charsUsed, out int bytesUsed, out bool completed)
 Converts an array of Unicode characters to an encoded byte sequence and stores the result in an array of bytes. More...
 
virtual unsafe void Convert (char *chars, int charCount, byte *bytes, int byteCount, bool flush, out int charsUsed, out int bytesUsed, out bool completed)
 Converts a buffer of Unicode characters to an encoded byte sequence and stores the result in another buffer. More...
 

Protected Member Functions

 Encoder ()
 Initializes a new instance of the T:System.Text.Encoder class. More...
 

Properties

EncoderFallback Fallback [get, set]
 Gets or sets a T:System.Text.EncoderFallback object for the current T:System.Text.Encoder object. More...
 
EncoderFallbackBuffer FallbackBuffer [get]
 Gets the T:System.Text.EncoderFallbackBuffer object associated with the current T:System.Text.Encoder object. More...
 

Detailed Description

Converts a set of characters into a sequence of bytes.

Definition at line 11 of file Encoder.cs.

Constructor & Destructor Documentation

◆ Encoder()

System.Text.Encoder.Encoder ( )
protected

Initializes a new instance of the T:System.Text.Encoder class.

Definition at line 82 of file Encoder.cs.

Member Function Documentation

◆ Convert() [1/2]

virtual void System.Text.Encoder.Convert ( char []  chars,
int  charIndex,
int  charCount,
byte []  bytes,
int  byteIndex,
int  byteCount,
bool  flush,
out int  charsUsed,
out int  bytesUsed,
out bool  completed 
)
virtual

Converts an array of Unicode characters to an encoded byte sequence and stores the result in an array of bytes.

Parameters
charsAn array of characters to convert.
charIndexThe first element of chars to convert.
charCountThe number of elements of chars to convert.
bytesAn array where the converted bytes are stored.
byteIndexThe first element of bytes in which data is stored.
byteCountThe maximum number of elements of bytes to use in the conversion.
flushtrue to indicate no further data is to be converted; otherwise, false.
charsUsedWhen this method returns, contains the number of characters from chars that were used in the conversion. This parameter is passed uninitialized.
bytesUsedWhen this method returns, contains the number of bytes that were produced by the conversion. This parameter is passed uninitialized.
completedWhen this method returns, contains true if all the characters specified by charCount were converted; otherwise, false. This parameter is passed uninitialized.
Exceptions
T:System.ArgumentNullExceptionchars or bytes is null (Nothing).
T:System.ArgumentOutOfRangeExceptioncharIndex , charCount , byteIndex , or byteCount is less than zero.-or-The length of chars - charIndex is less than charCount .-or-The length of bytes - byteIndex is less than byteCount .
T:System.ArgumentExceptionThe output buffer is too small to contain any of the converted input. The output buffer should be greater than or equal to the size indicated by the Overload:System.Text.Encoder.GetByteCount method.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoder.Fallback is set to T:System.Text.EncoderExceptionFallback.

Definition at line 242 of file Encoder.cs.

◆ Convert() [2/2]

virtual unsafe void System.Text.Encoder.Convert ( char *  chars,
int  charCount,
byte *  bytes,
int  byteCount,
bool  flush,
out int  charsUsed,
out int  bytesUsed,
out bool  completed 
)
virtual

Converts a buffer of Unicode characters to an encoded byte sequence and stores the result in another buffer.

Parameters
charsThe address of a string of UTF-16 encoded characters to convert.
charCountThe number of characters in chars to convert.
bytesThe address of a buffer to store the converted bytes.
byteCountThe maximum number of bytes in bytes to use in the conversion.
flushtrue to indicate no further data is to be converted; otherwise, false.
charsUsedWhen this method returns, contains the number of characters from chars that were used in the conversion. This parameter is passed uninitialized.
bytesUsedWhen this method returns, contains the number of bytes that were used in the conversion. This parameter is passed uninitialized.
completedWhen this method returns, contains true if all the characters specified by charCount were converted; otherwise, false. This parameter is passed uninitialized.
Exceptions
T:System.ArgumentNullExceptionchars or bytes is null (Nothing).
T:System.ArgumentOutOfRangeExceptioncharCount or byteCount is less than zero.
T:System.ArgumentExceptionThe output buffer is too small to contain any of the converted input. The output buffer should be greater than or equal to the size indicated by the Overload:System.Text.Encoder.GetByteCount method.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoder.Fallback is set to T:System.Text.EncoderExceptionFallback.

Definition at line 297 of file Encoder.cs.

◆ GetByteCount() [1/2]

abstract int System.Text.Encoder.GetByteCount ( char []  chars,
int  index,
int  count,
bool  flush 
)
pure virtual

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.

Parameters
charsThe character array containing the set of characters to encode.
indexThe index of the first character to encode.
countThe number of characters to encode.
flushtrue to simulate clearing the internal state of the encoder after the calculation; otherwise, false.
Returns
The number of bytes produced by encoding the specified characters and any characters in the internal buffer.
Exceptions
T:System.ArgumentNullExceptionchars is null.
T:System.ArgumentOutOfRangeExceptionindex or count is less than zero.-or- index and count do not denote a valid range in chars .
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoder.Fallback is set to T:System.Text.EncoderExceptionFallback.

◆ GetByteCount() [2/2]

virtual unsafe int System.Text.Encoder.GetByteCount ( char *  chars,
int  count,
bool  flush 
)
virtual

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.

Parameters
charsA pointer to the first character to encode.
countThe number of characters to encode.
flushtrue to simulate clearing the internal state of the encoder after the calculation; otherwise, false.
Returns
The number of bytes produced by encoding the specified characters and any characters in the internal buffer.
Exceptions
T:System.ArgumentNullExceptionchars is null (Nothing in Visual Basic .NET).
T:System.ArgumentOutOfRangeExceptioncount is less than zero.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoder.Fallback is set to T:System.Text.EncoderExceptionFallback.

Definition at line 132 of file Encoder.cs.

◆ GetBytes() [1/2]

abstract int System.Text.Encoder.GetBytes ( char []  chars,
int  charIndex,
int  charCount,
byte []  bytes,
int  byteIndex,
bool  flush 
)
pure virtual

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.

Parameters
charsThe character array containing the set of characters to encode.
charIndexThe index of the first character to encode.
charCountThe number of characters to encode.
bytesThe byte array to contain the resulting sequence of bytes.
byteIndexThe index at which to start writing the resulting sequence of bytes.
flushtrue to clear the internal state of the encoder after the conversion; otherwise, false.
Returns
The actual number of bytes written into bytes .
Exceptions
T:System.ArgumentNullExceptionchars is null (Nothing).-or- bytes is null (Nothing).
T:System.ArgumentOutOfRangeExceptioncharIndex or charCount or byteIndex is less than zero.-or- charIndex and charCount do not denote a valid range in chars .-or- byteIndex is not a valid index in bytes .
T:System.ArgumentExceptionbytes does not have enough capacity from byteIndex to the end of the array to accommodate the resulting bytes.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoder.Fallback is set to T:System.Text.EncoderExceptionFallback.

◆ GetBytes() [2/2]

virtual unsafe int System.Text.Encoder.GetBytes ( char *  chars,
int  charCount,
byte *  bytes,
int  byteCount,
bool  flush 
)
virtual

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.

Parameters
charsA pointer to the first character to encode.
charCountThe number of characters to encode.
bytesA pointer to the location at which to start writing the resulting sequence of bytes.
byteCountThe maximum number of bytes to write.
flushtrue to clear the internal state of the encoder after the conversion; otherwise, false.
Returns
The actual number of bytes written at the location indicated by the bytes parameter.
Exceptions
T:System.ArgumentNullExceptionchars is null (Nothing).-or- bytes is null (Nothing).
T:System.ArgumentOutOfRangeExceptioncharCount or byteCount is less than zero.
T:System.ArgumentExceptionbyteCount is less than the resulting number of bytes.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoder.Fallback is set to T:System.Text.EncoderExceptionFallback.

Definition at line 193 of file Encoder.cs.

◆ Reset()

virtual void System.Text.Encoder.Reset ( )
virtual

When overridden in a derived class, sets the encoder back to its initial state.

Definition at line 89 of file Encoder.cs.

Property Documentation

◆ Fallback

EncoderFallback System.Text.Encoder.Fallback
getset

Gets or sets a T:System.Text.EncoderFallback object for the current T:System.Text.Encoder object.

Returns
A T:System.Text.EncoderFallback object.
Exceptions
T:System.ArgumentNullExceptionThe value in a set operation is null (Nothing).
T:System.ArgumentExceptionA new value cannot be assigned in a set operation because the current T:System.Text.EncoderFallbackBuffer object contains data that has not been encoded yet.
T:System.Text.EncoderFallbackExceptionA fallback occurred (see Character Encoding in the .NET Framework for fuller explanation)-and- P:System.Text.Encoder.Fallback is set to T:System.Text.EncoderExceptionFallback.

Definition at line 27 of file Encoder.cs.

◆ FallbackBuffer

EncoderFallbackBuffer System.Text.Encoder.FallbackBuffer
get

Gets the T:System.Text.EncoderFallbackBuffer object associated with the current T:System.Text.Encoder object.

Returns
A T:System.Text.EncoderFallbackBuffer object.

Definition at line 54 of file Encoder.cs.


The documentation for this class was generated from the following file: