PDA

View Full Version : How do you print super-special characters in C++



Eragon0605
January 16th, 2010, 05:05 PM
How do you print those extra-special characters, such as a one-character smiley and the single-character clubs symbol (like in cards), in C++. I somehow did it by accident at one point, but I just can't remember how to do it.

Zugzwang
January 16th, 2010, 05:10 PM
On the terminal, you can print only characters in the character set. The good old DOS codepage had the characters you described. But at least my Linux character set doesn't:



#include <iostream>

int main() {
std::cout << "\x01" << std::endl;
}

Eragon0605
January 16th, 2010, 05:16 PM
When I compile that, I get a blank window in linux. What is that supposed to print? Is there any way to get those sort of characters in Linux? I am running Ubuntu 9.10.

EDIT: Oh, and I assume that changing the "\x01" to, say, "\x02" would print a different character.

MindSz
January 16th, 2010, 05:17 PM
Look for an ASCII character table and just replace the hex value with whatever you want to print.

Zugzwang
January 16th, 2010, 05:22 PM
EDIT: Oh, and I assume that changing the "\x01" to, say, "\x02" would print a different character.

See here for a typical old DOS codepage, for example: http://en.wikipedia.org/wiki/Code_page_437

However, as already stated, in Linux, this doesn't work.

Eragon0605
January 16th, 2010, 05:23 PM
Look for an ASCII character table and just replace the hex value with whatever you want to print.
Thanks! It works, I don't know why I didn't think of that before... Anyway, the character prints, but it's really small. How do I make it bigger?

Zugzwang
January 16th, 2010, 05:26 PM
Thanks! It works, I don't know why I didn't think of that before... Anyway, the character prints, but it's really small. How do I make it bigger?

Increase the font size used by your terminal window.

Eragon0605
January 16th, 2010, 05:29 PM
Hahaha... Sorry, I haven't had my coffee yet, so I'm being a bit of an airhead.