I have the following piece of extremely simple code, which is supposed to output (amongst other things), three unicode characters:
/*
* To build:
* gcc -o curses curses.c -lncursesw
*
* Expected result: display these chars:
* http://www.fileformat.info/info/unicode/char/2603/index.htm (snowman)
* http://www.fileformat.info/info/unicode/char/26c4/index.htm (snowman without snow)
* http://www.fileformat.info/info/unicode/char/1f638/index.htm (grinning cat face with smiling eyes)
*
* Looks like ncurses is NOT able to display second and third char
* (only the first one is OK...)
*/
#include <ncurses.h>
#include <stdio.h>
#include <locale.h>
int
main (int argc, char *argv[])
{
WINDOW *stdscr;
char buffer[] = {
'<',
0xE2, 0x98, 0x83, // U+2603 : snowman: OK
0xE2, 0x9B, 0x84, // U+26C4 : snowman without snow: ERROR (space displayed)
0xF0, 0x9F, 0x98, 0xB8, // U+1F638: grinning cat face: ERROR (space displayed)
'>',
'\0' };
setlocale (LC_ALL, "");
stdscr = initscr ();
mvwprintw (stdscr, 0, 0, buffer);
getch ();
endwin ();
/* output the buffer outside of ncurses */
printf("%s\n",buffer);
return 0;
}
The final printf outputs all the characters as I'd expect "<☃⛄