This C# program demonstrates how to encode ASCII and Unicode (UTF-16) characters and display them via the console window.
using System; using System.Text; namespace XoaX { class Program { static void Main(string[] args) { Console.WriteLine("ASCII - 1 byte per character"); Console.WriteLine("ASCII: Forward Slash: 0x2F -> \x2F"); Console.WriteLine("ASCII: At Symbol: 0x40 -> \x40"); Console.WriteLine(); Console.WriteLine("Unicode - 2 bytes per character"); Console.WriteLine("Unicode UTF-16: At Symbol: 0x0040 -> \u0040"); Console.WriteLine("Unicode UTF-16: Capital Pi: 0x03A0 -> \u03A0"); Console.WriteLine(); Console.WriteLine("Some characters do not display in the current encoding."); Console.WriteLine("Unicode UTF-16: Latin Small Letter ESH: 0x0283 -> \u0283"); Console.WriteLine(); Console.OutputEncoding = Encoding.Unicode; Console.WriteLine("They do get displayed with a different encoding."); Console.WriteLine("Unicode UTF-16: Latin Small Letter ESH: 0x0283 -> \u0283"); } } }
ASCII - 1 byte per character ASCII: Forward Slash: 0x2F -> / ASCII: At Symbol: 0x40 -> @ Unicode - 2 bytes per character Unicode UTF-16: At Symbol: 0x0040 -> @ Unicode UTF-16: Capital Pi: 0x03A0 -> Π
Some characters do not display in the current encoding. Unicode UTF-16: Latin Small Letter ESH: 0x0283 -> ? They do get displayed with a different encoding. Unicode UTF-16: Latin Small Letter ESH: 0x0283 -> ʃ
Press any key to continue . . .
© 20072025 XoaX.net LLC. All rights reserved.