3

I cant seem to find a general explanation for how to use extended ascii characters. I am specifically trying to use the different pipe variations for a minimap in my roguelike game.

    static Encoding e = Encoding.GetEncoding("iso-8859-1");
    string shown = e.GetString(new byte[] { 185 });

This code displays "1" even though all of the extended ascii tables show the pipe going in the top, left, bottom directions. Please help!

  • 1
    Can you attach a screenshot of the result? – Chayim Friedman Sep 25 '18 at 06:56
  • 2
    Looking at [ISO_8859-1](https://de.wikipedia.org/wiki/ISO_8859-1), 185d (0xB9) is actually the symbol ¹. So your output is what I would expect. – Rev Sep 25 '18 at 07:06
  • 1
    You can also just hard code them: `Console.WriteLine("╔═╗"); Console.WriteLine("╚═╝");` which makes the code easy to read. Or use constants if that's easier: `private const char TopLeft = '╔';` – Rufus L Sep 25 '18 at 07:19
  • Also check out: https://stackoverflow.com/questions/17362509/how-to-use-symbols-of-extended-ascii-table-in-c – Rufus L Sep 25 '18 at 07:21
  • Thank you Rufus L! It is as simple as copy and pasting the characters from the wiki page to my program. Problem solved! – Christian Swierc Sep 25 '18 at 21:11

1 Answers1

0

You shoud change your Console.OutputEncoding:

Encoding e = Encoding.GetEncoding("iso-8859-1");
Console.OutputEncoding = e;

then Console.WriteLine(shown); should display the desired result.

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171