Console Applications

P

Paolo

Is there a way of accessing the various graphics characters to facilitate
drawing on the screen in console apps. I don't want to use the '-' (hyphen)
character - I thoughtthere were some 'graphics' characters hat were
available. I've looked at the Console Class specs and can't find anything
about this. Any advice would be appreciated.

Thanks
 
J

Jon Skeet [C# MVP]

Is there a way of accessing the various graphics characters to facilitate
drawing on the screen in console apps. I don't want to use the '-' (hyphen)
character - I thoughtthere were some 'graphics' characters hat were
available. I've looked at the Console Class specs and can't find anything
about this. Any advice would be appreciated.

Have a look at unicode.org and see if you can find appropriate
characters there. In particular http://www.unicode.org/charts/symbols.html
might be helpful to you. However, I don't know offhand whether console
apps will be able to support those characters - and it may very well
depend on which font the user has specified for their console.

Jon
 
M

Morten Wennevik [C# MVP]

Hi Paolo,

You can use all the characters in a codepage. These include extended
characters like ╚ █ ▓ ┼ etc which you can make graphics with. Use an ascii
lookup table to find the character number for these characters and write them
by writing the character number while holding the ALT key [ALT] + [200] = â•š

PS! The character number between 128 and 255 may change in various codepages
so you may get a different character for the 200.

Sample program:

static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.Blue;
Console.ForegroundColor = ConsoleColor.White;

Console.WriteLine("â•”â•â•â•â•â•â•â•â•â•â•â•â•â•â•—");
Console.Write("â•‘");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(" Hello World ");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("â•‘");
Console.WriteLine("â•šâ•â•â•â•â•â•â•â•â•â•â•â•â•â•");
Console.ResetColor();
Console.Read();
}
 
P

Paolo

Morten: thank you. I thought there might be an extended character set (having
used similar techniques in COBOL). I was worried might have to get into the
Windows API!

Morten Wennevik said:
Hi Paolo,

You can use all the characters in a codepage. These include extended
characters like ╚ █ ▓ ┼ etc which you can make graphics with. Use an ascii
lookup table to find the character number for these characters and write them
by writing the character number while holding the ALT key [ALT] + [200] = â•š

PS! The character number between 128 and 255 may change in various codepages
so you may get a different character for the 200.

Sample program:

static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.Blue;
Console.ForegroundColor = ConsoleColor.White;

Console.WriteLine("â•”â•â•â•â•â•â•â•â•â•â•â•â•â•â•—");
Console.Write("â•‘");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(" Hello World ");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("â•‘");
Console.WriteLine("â•šâ•â•â•â•â•â•â•â•â•â•â•â•â•â•");
Console.ResetColor();
Console.Read();
}

--
Happy Coding!
Morten Wennevik [C# MVP]


Paolo said:
Is there a way of accessing the various graphics characters to facilitate
drawing on the screen in console apps. I don't want to use the '-' (hyphen)
character - I thoughtthere were some 'graphics' characters hat were
available. I've looked at the Console Class specs and can't find anything
about this. Any advice would be appreciated.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top