I'm running CodeBlocks in Windows 10 and even after following some of the indications found on SO, I did not manage to print in cosole utf8 chars.
_setmode(_fileno(stdout), 0x00020000); // _O_U16TEXT
setlocale(LC_ALL, "C.UTF-8");
wchar_t star = 0x2605;
wchar_t st = L'★';
if (printf("%lc\n", star) < 0) {
perror("printf");
}
if (printf("\n%lc\n", st) < 0) {
perror("printf");
}
gives the output
printf: Invalid argument
printf: Invalid argument
The console Properties >> Font is set to Lucida Console, similar to codeblocks code editor. I am able to see the star as a symbol inside my text editor but not in the console. What should I do?
EDIT:
even if I change the previous code to:
if (wprintf(L"%lc", star) < 0) {
perror("printf");
}
printf("\n");
if (wprintf(L"%lc", st) < 0) {
perror("printf");
}
I am not able to see more than two rectangles instead of the stars (which if I copy and try to paste them here, are drawn in the right way)