0

I'm learning at a nice pace right now trying to rekindle what I almost forgot in programming. Right now I'm re-reviewing the basics of C# coding and I came across an interesting subject on ascii and unicode. The instructor, who I'm learning from online of course, mentioned you can make symbols with either. So I figured, heck yeah I'll do that. I wanted to make a symbol, in Console while using C# with Visual Studio, that shows a capricorn symbol, followed by a heart, and a gemini symbol. Basically saying I (the Capricorn) love(the heart) my girlfriend (The Gemini) using symbols. I assumed it was unicode. However, when I do try to write the line, I get boxes with question marks on all accounts. Here is my code:

using System;
using System.Text;
class EntryPoint
{
    static void Main()
    {
        Console.InputEncoding = Encoding.UTF8;
        Console.OutputEncoding = Encoding.UTF8;
        //Changes the input and output of the console's encoding

        char theGeminiCharacter = '\u264A';
        char theCapricornCharacter = '\u2651';
        char theHeartCharacter = '\u2764';
        string freeSpace = " ";
        //Can't seem to find the right unicode process to make the zodiac signs. 

        Console.WriteLine(theCapricornCharacter + freeSpace + theHeartCharacter + freeSpace + theGeminiCharacter);
    }

}

So, what am I doing wrong here? Is it even supposed to be unicode or is there some other code type? I've heard of Alt+X but I didn't really understand it. Thanks in advance!

Lockeheede
  • 11
  • 1
  • It's probably the font that is showing the text doesn't support the unicode characters you are trying to show. – gunr2171 Sep 25 '19 at 15:49
  • Here's the listing for zodiac unicode characters: https://en.wikipedia.org/wiki/Zodiac#Unicode_characters – gunr2171 Sep 25 '19 at 15:50
  • The question is mostly if the *Windows Console* supports those characters. And something as simple as the Font not having a symbol for it can totally get in the way. That console was old, when I young. .NET supports unicode. All strings are full unicode. | So my best adivse is to start with Windows Forms as your lowest Display technology. – Christopher Sep 25 '19 at 15:52
  • This article might help you understand the difference (or lack of difference) between ASCII and Unicode: https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/ – Christopher Sep 25 '19 at 15:54
  • @Christopher, wait wait wait, is that _A RECOMMENDATION_ to use WinForms? Gasp! The horror! : ) – gunr2171 Sep 25 '19 at 16:00
  • 1
    Possible duplicate of [How to use unicode characters in Windows command line?](https://stackoverflow.com/questions/388490/how-to-use-unicode-characters-in-windows-command-line) – Dour High Arch Sep 25 '19 at 16:01
  • @gunr2171: .NET Core 3.0 will have WinForms support added. And yes, for trying out some simple stuff or learning Multtiasking I usually advise for WindowsForms. It is the simplest Display Technology I **know** can deal with Unicode and Multitasking. – Christopher Sep 25 '19 at 16:11
  • 1
    @Christopher I'm mostly joking, but I agree that WinForms is a great "get started quick" tech. – gunr2171 Sep 25 '19 at 16:12
  • I know I can click the top left corner of the console to edit the preferences. I'm just not sure which font to choose when I do that... Edit: OOpps, DejaVu Sans Mono worked – Lockeheede Sep 25 '19 at 16:29
  • @Lockeheede Does that mean the problem is solved now? You can write an answer yourself, mentioning which fonts work and which don't. – Mr Lister Sep 25 '19 at 17:24

1 Answers1

1

Yes. It is answered. I noticed that certain fonts just don't do all of the UTF08 Input/Outputs, This particular one (DejaVu Sans Mono) did indeed work. The issue was just font types. Just not sure how to choose that my question was solved.

Lockeheede
  • 11
  • 1
  • You can accept your own answer by clicking the checkmark to the left of the answer. There's a waiting period though before you can. – Mr Lister Sep 26 '19 at 06:05