how do I use special characters

Dec 17, 2008 at 7:11pm
I am working on a blackjack game where I want to show the cards like this: A♣ for the ace of spades. Ive tryed copy/paste and "/U2660". neither worked. How can I do this?

Thank you for the help.
Dec 17, 2008 at 7:20pm
I'll assume you're using cmd.exe as terminal.
cmd.exe sucks at Unicode. If they were going to write a console emulator, I don't know why Microsoft didn't pimped it up a bit. I mean, just look at Konsole, for example.

Anyway, you could one of the sub U+0020 characters for this:
Spade: (char)6
Club: (char)5
Heart: (char)3
Diamond: (char)4
I don't like this approach very much, though.

And now, I'm so dissatisfied I'm going to go look for a console emulator with better Unicode support.
Dec 17, 2008 at 7:43pm
Helios Thank you for your reply. I just figured out what I had wrong. I was using the upper case 'U' and not a lower case 'u'. Now that I have that fixed I see what you mean by "cmd.exe sucks at Unicode". Instead of the pretty spade (haha I showed a club not a spade. oops) , I get 3 odd looking characters.

What is a sub U+0020 character?

Here is the code I am using to test my unicode output.
1
2
3
4
{
cout << " \u2663 ";
cin.get();
}



Dec 17, 2008 at 8:07pm
Interesting...
'\u####' generates a UTF-8 string. I didn't know that.

You see? That's exactly what I mean. If cmd.exe was a decent terminal emulator, you'd had seen the expected result. A club suit symbol.

By "sub U+0020", I mean all ASCII characters in code points lower than space (' ', U+0020).
Try printing those values I posted earlier. std::cout <<(char)6<<std::endl;
Dec 17, 2008 at 8:20pm
Helios thank you! I copy and pasted your code and it was exactly what I needed thank you.

Would it be to much to ask you to explain what it is im doing here, and direct me to a complete list of these values for later reference

Thanks again, you were a big help.
Dec 17, 2008 at 8:28pm
I could, but I won't.
Using special characters to display the arbitrary images that were assigned to them is a bad idea, and I don't want you to get used to them.
Dec 17, 2008 at 8:41pm
Ok, thank your for your help.

Why is it a bad idea? From what Ive learned here, I can see there may be issues with consoles not supporting a code. Are there other reason why I should not use special characters in my all text programs?
Dec 17, 2008 at 8:55pm
Special characters are special because they whave special uses. Using them for something other than that is just asking for trouble.

Or, at least, that's what I think.
Last edited on Dec 17, 2008 at 9:42pm
Dec 17, 2008 at 9:29pm
Helios, I dont quite understand your answer. You seem to know your stuff, so I will keep your advice in mind. Until I learn how and when special characters should be used Ill limit my use of them.

I wasnt able to find a list online but I was able to edit your code to make a list of 256 characters. This is for anyone else that might be curious

1
2
3
4
for (int i=0;i<256;i++)
{
    std::cout << (char)i << " ";
}

Last edited on Dec 17, 2008 at 9:33pm
Dec 17, 2008 at 9:49pm
Yeah, the first 16 or so are special characters, they do beeps, newlines, tabs, etc...and the other special characters could theoretically get something assigned to them and screw up your program.
Topic archived. No new replies allowed.