Ncurses in UTF-8 locale

Ncurses in UTF-8 locale

Post by Chris Jone » Tue, 02 Jun 2009 21:04:05


I coded the following snippet:

#include <locale.h>
#include <ncurses.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int uc;

int main(void)
{
initscr();
raw();
keypad(stdscr, TRUE);
uc = getch();
mvprintw(24, 0, "Key code = %4x ", uc);
refresh();
getch();
endwin();
return 0;
}

This runs OK when locale is set to en_US but behaves unexpectedly when
set to en_US.utf8.

I tested on uxterm with:

Compose + E=

which is mapped to the euro symbol - 0x20ac.

When I enter this key combination, I am returned to the bash prompt with
an empty square/rectangle.

This runs OK if I hit any key that's mapped to an 8-bit encoded
character such as <space> .. 0, 1, .. etc.

Is this because there's something wrong with my testing, using the
Compose key or do I need to change the code above to get it to work in
a UTF-8 locale?

I played with the above, adding a setlocale(LC_ALL, "") .. linked to
libncursesw instead of linbncurses.. to no effect.

Since I saw no mention of UTF-8 in the ncurses manuals I was expecting
this to be transparent.

CJ
 
 
 

Ncurses in UTF-8 locale

Post by Chris Jone » Thu, 04 Jun 2009 07:01:12


[..]

Come to think of it, I may have assumed wrong & posted this request for
assistance in the wrong newsgroup - same developer as xterm and seems to
have at some point been shipped with Xfree86 - but since ncurses is not
X specific, perhaps s/o could suggest a better place?

CJ