This is my code:
Console.WriteLine("•");
Or this:
Console.WriteLine("\u2022");
The result (on my computer):
*beep*
The desired result:
•
How can I make the above character appear on my console?
I understand where the beep comes from, as the bullet is translated into an ASCII BELL
character. This question came about while trying to understand more about codepage 437.
This seems to solve the problem much easier than the other options listed. (And it's available now, even if it wasn't when the question was originally asked.)
Console.OutputEncoding = System.Text.Encoding.UTF8;
I just remembered a Windows console mode that doesn't process ASCII codes such as the bell and linefeed. I need these functions:
[DllImport("kernel32.dll")]
static extern IntPtr GetStdHandle(int handle);
[DllImport("kernel32.dll")]
static extern bool SetConsoleMode(IntPtr handle, int mode);
Before I try writing to the console, I do this:
SetConsoleMode(GetStdHandle(-11), 2);
This fetches a handle to the native screen buffer attached to stdout, and disables the ENABLE_PROCESSED_OUTPUT flag.
Console.WriteLine("•");
Output:
•♪◙
Whoops, that means it won't process the linefeed and carriage return that come from WriteLine
.
Console.Write("•");
Output:
•
Bingo!
Now if I want to revert the console back to 'normal' mode before printing more text, I can do this:
SetConsoleMode(GetStdHandle(-11), 3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With