Reputation: 385
I want to store some of the extended ascii characters into a dictionary for lookup but having little issue with getting the conversion.
The current method I have to store these characters works for all the non-graphical looking ascii characters 0x20 to 0xAF.
Current method:
private static void LoadAnsiTable()
{
for (byte i = 0x20; i < 0xFE; i++)
{
AnsiLookup.Add(i, Convert.ToChar(i).ToString());
}
}
but the 0xAF and on does not have the ░ ▒ ▓ │ ┤╡ ╢ etc it just has these funky letters.
Looking at this table http://www.asciitable.com/ for reference.
This works if I manually add it,
AnsiLookup.Add(0xB0, "░");
I would like to know how I can get those symbols captured in some kind of collection without having to manually add them all?
Upvotes: 3
Views: 14182
Reputation: 54877
I assume your "Extended ASCII" is actually code page 437:
Encoding cp437 = Encoding.GetEncoding(437);
byte[] source = new byte[1];
for (byte i = 0x20; i < 0xFE; i++)
{
source[0] = i;
AnsiLookup.Add(i, cp437.GetString(source));
}
Beware that this code page is not natively supported by the .NET Framework, so it might not be available on all systems.
Upvotes: 9