Can't display sigma char in c #

I am trying to display sigma char in my application. I debugged this:

using System;
class Program{
    static void Main(){

        Console.Write("This is Omega: {0}.  And this is Sigma: {1} ",
        "\u03A9", "\u03A3");        
        Console.ReadLine();

    }//end Main
}//end class Program

      

Unfortunately my console displays the following text:

'This is Omega: O.  And this is Sigma: S'

      

I know it has to do with the encoding, but I can't seem to find a way to get it to work ...

Edit: Thread.CurrentThread.CurrentCulture.ToString () = fr-CH

+3


source to share


1 answer


You need to specify the console output encoding . Add this:

Console.OutputEncoding = System.Text.Encoding.Unicode;

      



before trying to execute the output. And of course, you must use a console font with glyphs for these characters. My system is configured to use Consolas, and with the OutputEncoding

above, the output looks like this:

enter image description here

+4


source







All Articles