I want to write UTF-8 Chars onto the terminal, but despite of trying everything I found here on stack overflow it doesn't work.
I build my program with the command "cc main.c -lncursesw" and I include ncurses/curses.h, wchar.h and locale.h.
As described in here (How to make ncurses display UTF-8 chars correctly in C?) I set the locale. I cannot access any function to print wide character and doing it prints two undesired ASCII chars. The (I think) relevant code:
#define unsetcolor(color) attroff(COLOR_PAIR(color))
#define to_full_color(f, b) (b << 3) | f | 64
#define setcolor(color) attron(COLOR_PAIR(color))
void init_colorpairs()
{
for(int f = 0; f < 8; f++)
{
for(int b = 0; b < 8; b++)
{
//I just do color things
int color_pair = to_full_color(f, b);
init_pair(color_pair, f, b);
}
}
}
int main()
{
setlocale(LC_ALL, "");
WINDOW* main_win = initscr();
if(has_colors() == FALSE)
{
return -1;
}
start_color();
init_colorpairs();
//window size x, y
int win_s_x, win_s_y;
getmaxyx(main_win, win_s_y, win_s_x);
//curs_set(0);
//0=succsess, -1=error
attron(A_BOLD);
for(int i = 0; i < (win_s_x * win_s_y); i++)
{
u8 color = (i&63)|64;
setcolor(color);
//My try to print an UTF-8 char, i also searched for addchw or mvaddv
addch(9617);
unsetcolor(color);
}
refresh();
attroff(A_BOLD);
//refresh();
getch();
endwin();
return 0;
}