Converting Existing Encodings

Many different schemes have been developed for representing the characters in a language as numeric codes within a computer. These schemes are referred to as encodings . The .NET Framework provides support for encodings through the System.Text.Encoding class.

Internally, preferred encoding for characters is 16-bit Unicode, commonly known as UTF-16. This encoding represents characters as 16-bit numbers , giving the .NET Framework the capability to represent approximately 65,000 distinct characters.

The System.Text namespace contains classes designed to let you convert characters from the UTF-16 Unicode encoding to other encodings, and vice versa. You might need to use these classes for compatibility or communication with older applications. Table 10.1 lists these classes.

Table 10.1. Encoding Classes in the System.Text Namespace

Class

Use

ASCIIEncoding

Converts characters between Unicode and ASCII.

Encoding

Functions as a general-purpose class. The Encoding.GetEncoding() static method returns encodings that can be used for legacy code page compatibility.

UnicodeEncoding

Converts characters to and from Unicode-encoded text as consecutive bytes in either big-endian or little-endian order.

UTF7Encoding

Converts characters to and from 7-bit Unicode encoding.

UTF8Encoding

Converts characters to and from 8-bit Unicode encoding.



MCAD Developing and Implementing Web Applications with Visual C#. NET and Visual Studio. NET (Exam [... ]am 2)
MCAD Developing and Implementing Web Applications with Visual C#. NET and Visual Studio. NET (Exam [... ]am 2)
ISBN: 789729016
EAN: N/A
Year: 2005
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net