O'Reilly logo

.NET Common Language Runtime Unleashed by Kevin Burton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required