I am trying to print characters that are apart of the ASCII Extended table in ncurses, but printw() only supports printable characters that are 8-bits long. printf() however allows you to print characters above 8-bits. I want to use ncurses functions such as move() to move the placement of my cursor while also using printf() to print out the characters above 8-bits.
There are a few ways to solve this problem.
1) Somehow allow output while in ncurses mode for characters above 8-bits. This includes printw(), addch(), wprintw(), etc. I have asked questions on this topic before, with limited outcome. addch() in my Ubuntu compiler will print some ASCII values above 8-bits, but not all of them. Such functions as
addch(ACS_S1); addch(ACS_LANTERN);
doesn't print out the character, but rather prints out
⍰
2) Have printf() work simultaneously with ncurses functions like move() and init_color() so that I can print the characters above 8-bits. The reason I am having trouble with this is because when you use refresh() in ncurses, it clears the bottom screen replacing it with the window you are using. printf() either gets eradicated, or it won't work alongside move(). I think there might be a move function that moves cursors on specific windows, which in that case I might be able to move print, but I don't know the function nor the screen that printf resides on
I am using Ubuntu if that is a part of the problem. I don't think it is, but I am including it just encase. Any help would be seriously appreciated.
The question says:
I am trying to print characters that are apart of the ASCII Extended table in ncurses, but printw() only supports printable characters that are 8-bits long.
Actually, ncurses's ncursesw library (generally available since 2002) handles multibyte characters (e.g., UTF-8), so printw handles strings like this:
char *foo = " { 0x04a6, 0x30f2 }, /* kana_WO ヲ KATAKANA LETTER WO */";
printw ("%s", foo);
It won't interpret things like this as you might expect:
wchar_t foo = 0x04a6;
printw ("%c", foo);
since the underlying C runtime will insist that %c refers to a char, not wchar_t. That all relies upon initializing the locale and using the right library.
It's certainly possible to mix stdio and curses, but that won't solve the problem you're asking about (and to do this successfully requires some work). I've done this in ded (directory editor) for about 30 years, using part of the screen with curses, and part without.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With