views:

71

answers:

2

I am able to correctly display the standard ASCII symbols (up to 127) like "heart", "note" you know what I mean. I would like to also display ones that I can use for drawing walls (like U0205) but it does not work..well, it works but it looks like "?". Any way how I can display them? Thank you.

A: 

The problem appears to be with the Console application rather than with your program. The standard console in windows (cmd.exe) appears not to support Unicode properly - for example, try copying the string below and pasting directly into a cmd.exe window:

Fußball Ö ü

PowerShell seems to suffer from the same problem as well.

One possible solution to your problem is to create a dedicated window/form to be used as an "output console" instead of using the actual console through which the application was executed.

Hershi
Those characters display just fine for me in the console window and PowerShell under Server 2008 using the default raster fonts. What version of Windows are you running?
Cody Gray
+4  A: 

Console mode apps are restricted to an 8-bit code page encoding. The default on many machines is IBM437, the code page that matches the old IBM PC character set. You can change the code page by assigning the OutputEncoding property:

        Console.OutputEncoding = Encoding.UTF8;

But now you typically have a problem with the font. Consoles default to the Terminal font, an old device font that had glyphs in the right place to produce the IBM PC character set. There are not a lot of fonts available that can produce the proper glyphs that match the Unicode codepoints. Consolas is about it, available on Vista and Win7.

But that's not what you are asking, I think, I'm guessing that you are actually asking about the old box drawing characters. That works without any tinkering with the console settings, you just have to use the right Unicode characters. Here's an example that ought to survive a copy-and-paste:

class Program {
    static void Main(string[] args) {
        Console.WriteLine("╒════════╕");
        Console.WriteLine("│ Hello  │");
        Console.WriteLine("│ world  │");
        Console.WriteLine("╘════════╛");
        Console.ReadLine();
    }
}

To find these characters, use the Windows charmap.exe applet. Click the "Advanced view" checkbox and type "box" in the "Search for" text box, the grid will fill with the box drawing characters. The first usable one that will properly convert to the console is '\u250c'.

Hans Passant