System.Text

The System.Text namespace contains classes that deal with converting from one character encoding to another. The input is assumed primarily to be Unicode. The output varies with the encoding class that is selected. Listing B.59 shows an example of using the UTF8 encoding class (encoding.cs).

Listing B.59. Using UTF8 Encoding
 byte [] encoded; UTF8Encoding encoding = new UTF8Encoding(); Console.WriteLine("CodePage: {0} ", encoding.CodePage); Console.WriteLine("EncodingName: {0} ", encoding.EncodingName); Console.WriteLine("WindowsCodePage: {0} ", encoding.WindowsCodePage); encoded = encoding.GetBytes(japanese); Console.WriteLine("Encoded Japanese: {0} <-> {1} ", japanese.Length, encoded.Length); encoded = encoding.GetBytes(chinese); ...

Get .NET Common Language Runtime Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.