[Serializable] |
An implementation of this class converts blocks of Unicode characters into blocks of encoded bytes through successive calls of the Encoder.GetBytes method. This class maintains state information between successive calls of Encoder.GetBytes, enabling it to encode a character into a sequence of bytes, such as surrogate pairs, that span adjacent blocks. For example, this is useful for encoding a character into a surrogate pair.
The Encoder.GetByteCount method calculates the number of bytes required to encode a specified block of characters.
An instance of Encoder is typically obtained by calling the Encoding.GetEncoder method of a class derived from the Encoding class.
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetByteCount | When overridden in a derived class, calculates the number of bytes Encoder.GetBytes would produce from encoding the specified range of characters. |
GetBytes | When overridden in a derived class, encodes a specified range of characters in a character array and stores them in a specified range of a byte array. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
ctor #1 | Default constructor. This constructor is called by derived class constructors to initialize state in this type. Initializes a new instance of the Encoder class. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
protected Encoder(); |
~Encoder(); |
chars
index
count
flush
Exception Type | Condition |
---|---|
ArgumentNullException | chars is null. |
ArgumentOutOfRangeException | index or count is less than zero. -or- index plus count is greater than the length of chars. |
The state of the encoder is not affected by calling this method.
public abstract int GetBytes( |
chars
charIndex
charCount
bytes
byteIndex
flush
Exception Type | Condition |
---|---|
ArgumentNullException | chars or bytes is null. |
ArgumentOutOfRangeException | charIndex, charCount, or byteIndex is less than zero. -or- charIndex plus charCount is greater than the length of chars. -or- byteIndex plus charCount is greater than the length of bytes. |
It is recommended that you always call Encoder.GetByteCount before calling Encoder.GetBytes because the Encoder.GetBytes method might change the internal state information between blocks of bytes.
The flush parameter is useful for flushing a high-surrogate at the end of a stream that does not have a low-surrogate. For example, the Encoder created by UTF8Encoding.GetEncoder uses this parameter to determine whether to write out a dangling high-surrogate at the end of a character block.
public virtual int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
public virtual string ToString(); |