Source Code File 04-11_unicode
04-11_unicode.c
#define _XOPEN_SOURCE_EXTENDED 1 #include <ncurses.h> #include <locale.h> int main() { cchar_t heart = { A_NORMAL, L"\u2665" }; /* activate Unicode character set */ setlocale(LC_CTYPE,"en_US.UTF-8"); initscr(); addstr("I "); add_wch(&heart); addstr(" Ncurses"); refresh(); getch(); endwin(); return(0); }
Output Screenshot
Notes
* Remember that you may need to link with the ncursesw
library instead of ncurses
. Even then, not every Ncurses installation supports these features. If not, use your distro's package manager to install wide-character Ncurses.
* For more details on Unicode programming in C, refer to my blog.
Copyright © 1997-2024 by QPBC.
All rights reserved