I am trying to make a simple game using the ncursesw library which I am basically a complete noob at. I got the library working and I am now able to compile programs successfully with it. Now I am trying to print out unicode characters using this library but I can't get them to display. I don't have enough experience with curses to find out what is happening on my own, so I would really appreciate any help on this problem.
I built a sample program that prints out all charactes from 0 to 1023 using the addwstr function but visible output to the console stops right after the 127 point (DEL - represented as '^?') except for a few repetitions of a weird hexagon with a question mark in the middle some iterations later.
#define _XOPEN_SOURCE 700
#include <locale.h>
#include <ncursesw/curses.h>
int main(void)
{
setlocale(LC_ALL, "en_US.UFT-8");
wchar_t string[2];
string[0] = (wchar_t)0;
string[1] = (wchar_t)0x0;
initscr(); //init ncurses mode
for(int i = 0; i < 64; i++) {
for(int j = 0; j < 64; j++) {
addwstr(string);
string[0]++;
}
addwstr(L"\n");
}
refresh(); //display updates to buffer
getch();
endwin();
return 0;
}
I am testing this all out on a minimal debian install using i3. I already ran the program on both xterm and alacritty but got the same result as described above. If anyone has any idea of what is wrong with my code please share your thoughts.
My end goal is to be able o print the U+2588 character for my game. I also tried using the WACS_BLOCK macro but that only adds a '#' to the screen.
So I solved my own problem... All I had to do was to correctly spell UTF-8 in the setlocale function. I would normally delete this but I feel like this can help a lot of people trying to set up a basic ncursesw program since ther is barely any easy to digest documentation on this library. It took me like 3 hours to dig through the ncurses man pages and random 2000s websites to get this working