C++ Console APP special Characters

Started by
16 comments, last by benryves 14 years, 2 months ago
I want to be able to use special characters in my console application because Im making a tic tac toe game, I need to see these chars - " ╔═══╦═══╦═══╗ ". I tried changing my IDE font to terminal like the console output font but it still didnt work. All that shows are question marks "????????????" Any ideas?
Advertisement
Which are you having a problem with, having the characters show up in your program or having the characters show up in your IDE?
They show in the IDE, not in my console application. The actual program..
If you're using windows, I think you can do something like:

#include <iostream>int main(){   std::cout << char(x); //Where x is the ASCII code of the character you want} //end f()


Google ASCII Chart or ASCII table and you should be able to come up with a list of the ASCII character codes and the character they produce.
The IDE is displaying the Unicode characters, while your console is (most likely) displaying the IBM extended ascii charset. I.e. in Unicode, ╔ is L'\x2554' whereas in a console, ╔ is '\x69'
What method are you using to display your characters?
cout << "special chars here";
To be able to display those special characters you have to type cast ints. You could make consts for each character you want displayed and then with a cout
cout << char(someInt);

I know a few IDEs that don't display the characters but the console does. And only Windows I believe, since those characters you showed are windows special characters.

This will help. It is a list of all the numbers and their corresponding character.

This is a program I made that actually uses those characters. Doing the char(int) approach was the only way I could find to get those displayed, even copying and pasting wasn't working.
I have to print tons of theses characters, if possible Id like to put them into one block " " and somehow print them..
Depending on your operating system, you may be able to use system calls to display arbitrary unicode characters. For example, on Windows you should be able to do something like:
  WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), L" ╔═══╦═══╦═══╗ ", 16, 0, 0);

to dump a wide character string to the console.

This topic is closed to new replies.

Advertisement