c++ - Attributes for UTF-8 characters -
ncurses can display characters attached attributes via chtype
s, constructed or'ing single character attributes bitmasks thusly :
addch('a' | a_reverse);
however, after enabling utf-8 support, pushing multibyte character screen must done via addstr(char const*)
, , there no room attributes.
is there possibility of keeping attributes multibyte characters, or should keep track of them myself , use attron()
/attroff()
when needed ?
there 4 character types can used ncurses:
char
(forwaddstr
)chtype
(forwaddchstr
)wchar_t
(forwaddnwstr
)cchar_t
(forwadd_wchstr
)
the char
, chtype
data came first, 8-bit encodings. wchar_t
, cchar_t
came later wide-characters. latter of each pair former combined video attributes , color.
ncurses differs x/open curses allowing multibyte characters added via waddstr
(and waddch
) interfaces. "ncursesw" library (the "ncurses" library 8-bit encodings).
wchar_t
holds more bits char
.
on linux, wchar_t
(almost) synonymous unicode. not portable, ncurses uses wide-character functions convert wchar_t
needed utf-8 — or whatever terminal using encoding. likewise, input waddstr
may utf-8, ncurses uses corresponding multibyte-character functions converting application's locale-encoding wchar_t
values.
Comments
Post a Comment