Encoder Class
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Converts a set of characters into a sequence of bytes.
Assembly: mscorlib (in mscorlib.dll)
The Encoder type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Convert(Char*, Int32, Byte*, Int32, Boolean, Int32%, Int32%, Boolean%) | Security Critical. Converts a buffer of Unicode characters to an encoded byte sequence and stores the result in another buffer. |
![]() | Convert(array<Char>, Int32, Int32, array<Byte>, Int32, Int32, Boolean, Int32%, Int32%, Boolean%) | Converts an array of Unicode characters to an encoded byte sequence and stores the result in an array of bytes. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetByteCount(Char*, Int32, Boolean) | Security Critical. 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. |
![]() | GetByteCount(array<Char>, Int32, Int32, Boolean) | 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. |
![]() | GetBytes(Char*, Int32, Byte*, Int32, Boolean) | Security Critical. 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. |
![]() | GetBytes(array<Char>, Int32, Int32, array<Byte>, Int32, Boolean) | 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. |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
To obtain an instance of an implementation of the Encoder class, call the GetEncoder method of an Encoding implementation. There are two such implementations available in the .NET Framework for Windows Phone: UTF8Encoding and UnicodeEncoding. The UnicodeEncoding implementation supports both big-endian and little-endian Unicode.
The GetByteCount method determines how many bytes result in encoding a set of Unicode characters, and the GetBytes method performs the actual encoding. The Encoder class includes Several overloads of both methods.
An Encoder object maintains state information between successive calls to the GetBytes or Convert methods so that it can correctly encode character sequences that span blocks. The Encoder also preserves trailing characters at the end of data blocks and uses the trailing characters in the next encoding operation. For example, a data block might end with an unmatched high surrogate, and the matching low surrogate might be in the next data block.
Note: |
|---|
When the application is done with a stream of data it should make sure that the state information is flushed by setting the flush parameter to true in the appropriate method call. |
When your application inherits from this class, it must override all the members.


Note: