Represents a character encoding.
Encoding Class Members |
|
| Visibility | Name | Value Type | Accessibility |
|---|---|---|---|
| public static | ASCII | Encoding | [ Get ] |
| public static | BigEndianUnicode | Encoding | [ Get ] |
| public | BodyName | String | [ Get ] |
| public | CodePage | Int32 | [ Get ] |
| public | DecoderFallback | DecoderFallback | [ Get , Set ] |
| public static | Default | Encoding | [ Get ] |
| public | EncoderFallback | EncoderFallback | [ Get , Set ] |
| public | EncodingName | String | [ Get ] |
| public | HeaderName | String | [ Get ] |
| public | IsBrowserDisplay | Boolean | [ Get ] |
| public | IsBrowserSave | Boolean | [ Get ] |
| public | IsMailNewsDisplay | Boolean | [ Get ] |
| public | IsMailNewsSave | Boolean | [ Get ] |
| public | IsReadOnly | Boolean | [ Get ] |
| public | IsSingleByte | Boolean | [ Get ] |
| public static | Unicode | Encoding | [ Get ] |
| public static | UTF32 | Encoding | [ Get ] |
| public static | UTF7 | Encoding | [ Get ] |
| public static | UTF8 | Encoding | [ Get ] |
| public | WebName | String | [ Get ] |
| public | WindowsCodePage | Int32 | [ Get ] |
| Visibility | Name | Parameters | Return Type |
|---|---|---|---|
| public | Clone | ( ) | Object |
| public static | Convert | ( Encoding srcEncoding , Encoding dstEncoding , Byte bytes ) | Byte |
| public static | Convert | ( Encoding srcEncoding , Encoding dstEncoding , Byte bytes , Int32 index , Int32 count ) | Byte |
| public | Equals | ( Object value ) | Boolean |
| public | GetByteCount | ( Char chars , Int32 index , Int32 count ) | Int32 |
| public | GetByteCount | ( Char chars ) | Int32 |
| public | GetByteCount | ( String s ) | Int32 |
| public | GetByteCount | ( Char chars , Int32 count ) | Int32 |
| public | GetBytes | ( Char chars , Int32 charCount , Byte bytes , Int32 byteCount ) | Int32 |
| public | GetBytes | ( Char chars , Int32 charIndex , Int32 charCount , Byte bytes , Int32 byteIndex ) | Int32 |
| public | GetBytes | ( String s , Int32 charIndex , Int32 charCount , Byte bytes , Int32 byteIndex ) | Int32 |
| public | GetBytes | ( Char chars , Int32 index , Int32 count ) | Byte |
| public | GetBytes | ( String s ) | Byte |
| public | GetBytes | ( Char chars ) | Byte |
| public | GetCharCount | ( Byte bytes ) | Int32 |
| public | GetCharCount | ( Byte bytes , Int32 count ) | Int32 |
| public | GetCharCount | ( Byte bytes , Int32 index , Int32 count ) | Int32 |
| public | GetChars | ( Byte bytes , Int32 index , Int32 count ) | Char |
| public | GetChars | ( Byte bytes , Int32 byteCount , Char chars , Int32 charCount ) | Int32 |
| public | GetChars | ( Byte bytes ) | Char |
| public | GetChars | ( Byte bytes , Int32 byteIndex , Int32 byteCount , Char chars , Int32 charIndex ) | Int32 |
| public | GetDecoder | ( ) | Decoder |
| public | GetEncoder | ( ) | Encoder |
| public static | GetEncoding | ( Int32 codepage , EncoderFallback encoderFallback , DecoderFallback decoderFallback ) | Encoding |
| public static | GetEncoding | ( Int32 codepage ) | Encoding |
| public static | GetEncoding | ( String name ) | Encoding |
| public static | GetEncoding | ( String name , EncoderFallback encoderFallback , DecoderFallback decoderFallback ) | Encoding |
| public static | GetEncodings | ( ) | EncodingInfo |
| public | GetHashCode | ( ) | Int32 |
| public | GetMaxByteCount | ( Int32 charCount ) | Int32 |
| public | GetMaxCharCount | ( Int32 byteCount ) | Int32 |
| public | GetPreamble | ( ) | Byte |
| public | GetString | ( Byte bytes , Int32 index , Int32 count ) | String |
| public | GetString | ( Byte bytes ) | String |
| public | IsAlwaysNormalized | ( NormalizationForm form ) | Boolean |
| public | IsAlwaysNormalized | ( ) | Boolean |
Methods are provided to convert arrays and strings of Unicode characters to and from arrays of bytes encoded for a target code page.
A number of Encoding implementations are provided in the System.Text namespace, including:
The ASCIIEncoding class encodes Unicode characters as single 7-bit ASCII characters. This encoding only supports character values between U+0000 and U+007F.
The UnicodeEncoding class encodes each Unicode character as two consecutive bytes. Both little-endian ( code page 1200 ) and big-endian ( code page 1201 ) byte orders are supported.
The UTF7Encoding class encodes Unicode characters using the UTF-7 encoding ( UTF-7 stands for UCS Transformation Format, 7-bit form ). This encoding supports all Unicode character values, and can also be accessed as code page 65000.
The UTF8Encoding class encodes Unicode characters using the UTF-8 encoding ( UTF-8 stands for UCS Transformation Format, 8-bit form ). This encoding supports all Unicode character values, and can also be accessed as code page 65001.
Use the GetEncoding method with a code page or name parameter to obtain other encodings.
When the data to be converted is only available in sequential blocks ( such as data read from a stream ), an application can use a Decoder or an Encoder to perform the conversion. This is also useful when the amount of data is so large that it needs to be divided into smaller blocks. Decoders and encoders are obtained using the GetDecoder and GetEncoder methods. An application can use the properties of this class such as ASCII, Default, Unicode, UTF7, and UTF8 to obtain encodings. Applications can initialize new instances of Encoding objects through the ASCIIEncoding, UnicodeEncoding, UTF7Encoding, and UTF8Encoding classes.
Through an encoding, the GetBytes method is used to convert arrays of Unicode characters to arrays of bytes, and the GetChars method is used to convert arrays of bytes to arrays of Unicode characters. The GetBytes and GetChars methods maintain no state between conversions.
When the data to be converted is only available in sequential blocks ( such as data read from a stream ) or when the amount of data is so large that it needs to be divided into smaller blocks, an application can use a Decoder or an Encoder to perform the conversion. Decoders and encoders allow sequential blocks of data to be converted and they maintain the state required to support conversions of data that spans adjacent blocks. Decoders and encoders are obtained using the GetDecoder and GetEncoder methods.
The core GetBytes and GetChars methods require the caller to provide the destination buffer and ensure that the buffer is large enough to hold the entire result of the conversion. An application can use one of the following methods to calculate the required size of the destination buffer.
The first method generally uses less memory, whereas the second method generally executes faster.
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme