Hi,
I am not able to print the Unicode character on the console.
I tried with these API's
1) wprintf() displays ???????
2) _cwprintf() displays [][][][][][]
3) WriteConsoleW displays [][][][][][]
WriteConsoleW can display any characters present in the font your
console is using. A Windows font includes a default glyph that's
displayed when you ask to display a character for which the font doesn't
include a glyph -- and it looks like that's what you're getting here.
Consider the following code:
#include <windows.h>
int main() {
const int num = 256;
const int start = 0x100;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
wchar_t buffer[num];
for (wchar_t val = start; val<start+num; val++)
buffer[val-start] = val;
DWORD ignore;
WriteConsoleW(console, buffer, num, &ignore, NULL);
return 0;
}
When I run this on a console set to use the Lucida Console font, some
characters show proper glyphs and others show the default glyph (the
empty square box).
To get your code to work correctly, you'll need to ensure use of a font
that includes glyphs for the characters you're using. Unfortunately,
Windows has only minimal support for selecting the font to be used by a
particular console. It includes GetCurrentConsoleFont to retrieve
information about the font, but does NOT include a SetConsoleFont or
anything like that to change the font -- i.e. from the viewpoint of your
program, the font is read-only. Even at best, the selection of fonts for
a console is generally very limited.
Ultimately, however, this is really a question about system
administration rather than programming -- from a programming viewpoint,
WriteConsoleW (for one example) is doing what you've asked. You see the
glyph for the character you've specified; from there it's a matter of
selecting a font that includes suitable glyphs for the characters you're
using.