Code Comments
Programming Forum and web based access to our favorite programming groups.In curses (or ncurses), how can I output a UTF-8 encoded char* by using
addchstr() (or any other function taking a 'chtype' as argument)?
This (obviously) won't work:
(It's C99.)
const char* utf8Str = "Some UTF-8 text here";
chtype cursesStr[SOME_SIZE];
for (size_t i = 0; i < strlen(utf8Str); ++i) {
cursesStr[i] = utf8Str[i] | A_CURSES_ATTRIBUTE_WE_WANT;
}
cursesStr[i] = 0;
addchstr(cursesStr);
I guess I would have to combine every UTF-8 multibyte sequence in
utf8Str into a single chtype and store that in cursesStr. I can't seem
to succeed in it. Is it even possible to use addchstr() and friends for
UTF-8 strings? Or would I have to convert from UTF-8 to some other
Unicode encoding? If yes, which one? If no, what are my options?
Post Follow-up to this messageNikos Chantziaras <realnc@arcor.de> wrote: > In curses (or ncurses), how can I output a UTF-8 encoded char* by using > addchstr() (or any other function taking a 'chtype' as argument)? In ncurses, you can (assuming your locale is already using a UTF-8 encoding) use addstr. More generally (or to pass along an attribute), you would use setcchar, as illustrated in ncurse's test/view.c -- Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.