In the following program I am trying to provide a Unicode code point to the ncurses function setcchar() as an array string instead of as a string literal. However the output that I'm getting is the first character of the array only, namely the backslash character.
Is there another way to specify a Unicode code point other than as a string literal? And why are the two expressions L"\u4e09" and wcsarr not producing the same result in this context...
#define _XOPEN_SOURCE_EXTENDED 1
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <wchar.h>
#include <time.h>
int main() {
setlocale(LC_ALL, "");
cchar_t kanji;
wchar_t wcsarr[7];
wcsarr[0] = L'\\';
wcsarr[1] = L'u';
wcsarr[2] = L'4';
wcsarr[3] = L'e';
wcsarr[4] = L'0';
wcsarr[5] = L'9';
wcsarr[6] = L'\0';
initscr();
setcchar(&kanji, wcsarr, WA_NORMAL, 5, NULL);
addstr("Code point entered as an array string: ");
add_wch(&kanji);
addstr("\n");
setcchar(&kanji, L"\u4e09", WA_NORMAL, 5, NULL);
addstr("Code point entered as a string literal: ");
add_wch(&kanji);
addstr("\n");
refresh();
getch();
endwin();
return EXIT_SUCCESS;
}