First, you need to enable Unicode for console:
System.Console.OutputEncoding = System.Text.Encoding.UTF8;
System.Console.WriteLine("m²");
For "
m²
", "square" character is the Unicode code point U+00B2. So, the second line could also be written as:
System.Console.WriteLine("m\u00b2");
Remember that even though .NET supports all the encodings implemented as descendants of
System.Text.Encoding
, console may not support them all. Before answering, I made sure that at least UTF-8 and ASCII work (but ASCII will not show most Unicode characters, of course).
Please see:
http://msdn.microsoft.com/en-us/library/system.console.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.console.outputencoding.aspx[
^].
—SA