×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Printing utf8 chars in a console app

Printing utf8 chars in a console app

Printing utf8 chars in a console app

(OP)
I'm trying to make chess in a console application, and at the moment im just using letters to represent the pieces. I seen that in the utf-8 charecter set, you can find actual chess pieces, but im having some trouble printing them.

After looking on the net a bit, i have tried

SetConsoleOutputCP(65001);
wcout<<'?'<<endl;
wcout<<'\u2655'<<endl;

in both cases, it's just printing '?'

Anyone here has any idea how this works?
I'm using Visual studio c++ console application.

RE: Printing utf8 chars in a console app

Start your console with cmd /u

RE: Printing utf8 chars in a console app

(OP)
No.. it's not in cmd.exe, i want to print them from my own application..

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    SetConsoleOutputCP(65001);
    wcout<<'?'<<endl;
    wcout<<'\u9812'<<endl;
}

RE: Printing utf8 chars in a console app

Have you built it with the unicode flag set?

RE: Printing utf8 chars in a console app

May be, it's console font problem? If console font has not chess gliphs (for example, in my system(s) no console fonts to show chess at all, so no sense to declare any code pages;)...
This post presented for discussion only...

RE: Printing utf8 chars in a console app

(OP)
If you are refering to the Charecter set in the general selection of the project properties pages, it's set to "Use Unicode Charecter Set".

If not, any chance you can specify where I find it?

RE: Printing utf8 chars in a console app

The console will only take the Unicode characters available in Lucida Console font.  You can't display all the characters in Arial MS Unicode, which includes the chess characters you're talking about.

Note that consoles tend to be made up of non-proportional fonts.  Arial MS Unicode is a proportional font and can cause problems, especially with cursor addressing.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close