3

I'm trying to output θ (theta) on a console applicatation and I searched on Google and found that I have to use Unicode to output any greek symbols. So the code I used was:

Console.WriteLine("\u03B8 (deg)  R (m) \t T (kN)  FOS");

But instead of printing 'θ', '?' is printed. Can somebody advise me please?

BrunoLM
  • 97,872
  • 84
  • 296
  • 452
user2970331
  • 31
  • 1
  • 2

2 Answers2

4

If you're outputting to the console, you'll have to change your codepage to something that understands unicode. You can do this by typing chcp 65001 at a command prompt. You'll also have to change your font to Lucida Console or Consolas:

enter image description here

Edit: Well of course it's possible to do in C# as well:

    public static void Main()
    { 
        Console.OutputEncoding = System.Text.Encoding.Unicode;
        Console.WriteLine("\u03B8");
        Console.ReadLine();
    }

I think you'll still have to massage the font by hand (or by unmanaged code).

Reacher Gilt
  • 1,813
  • 12
  • 26
  • I am on `Win7 x64` and the console seems a bit buggy - at first I thought it didn't work after changing the font, but it corrected itself once I tabbed around a bit. Probably the window needs to redraw itself for encoding to take effect with a new font. – Superbest Feb 12 '14 at 13:40
2

See How to make Unicode charset in cmd.exe by default?

The answers to this question explain how to set up cmd.exe to display Unicode characters.

Specifically, this answer suggests changing the registry:

  1. Go to [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage]
  2. Change the OEMCP value to 65001
Community
  • 1
  • 1
Aniket Inge
  • 25,375
  • 5
  • 50
  • 78