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!

5
  • 1
    Can you attach a screenshot of the result? Commented Sep 25, 2018 at 6:56
  • 2
    Looking at ISO_8859-1, 185d (0xB9) is actually the symbol ¹. So your output is what I would expect. Commented Sep 25, 2018 at 7: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 = '╔'; Commented Sep 25, 2018 at 7:19
  • Also check out: stackoverflow.com/questions/17362509/… Commented Sep 25, 2018 at 7:21
  • Thank you Rufus L! It is as simple as copy and pasting the characters from the wiki page to my program. Problem solved! Commented Sep 25, 2018 at 21:11

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.