April 2002
Intermediate to advanced
1024 pages
23h 26m
English
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).
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); ... |