Dear Sirs,

I'd have a newbie question about unicode and ncurses under linux:
is there working examples showing correct way to implement unicode 
support with ncurses? Supposing I have program like this:
---
#include <stdio.h>
#include <locale.h>
#include <form.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv)
{
  chtype chs[6] = { 0 } ; 
  chtype wstr[20] ; 
  int i ; 

  setlocale(LC_CTYPE,"") ; 
  initscr();
  bkgdset(' ');
  noecho() ; 
  while((chs[0] = wgetch(stdscr)) != 27 ) {
    for(i=0 ; i<6 ; i++) 
      if(chs[i] != 0) {
        swprintf(wstr, 20,L"code %d ", (int)chs[i]) ;
        mvaddchstr(10+i, 5, wstr);
        wmove (stdscr,10+i,20) ; 
        addch(chs[i]) ;
      }
    for(i=5 ; i>0 ; i--) chs[i] = chs[i-1] ; 
  } 
  echo() ; 
  endwin() ; 
  return(0) ; 
}
---
then what is needed to make it unicode-aware? Right now when I run
this under utf-8 xterm and enter a non-ascii7-character the wgetch()
returns the utf-8 sequence, not single number representing the 
character. I tried to collect the sequence and fed it through 
mbtowc but to me it doesn't seem to be the Right Thing to do altought
it does seem to work, at least with glyphs also found from iso8859-1
but it failed when I tried to paste kanji glyphs to xterm running
this prog .. don't know if the problem is with cut'n'paste or my
thinking that first collecting the utf-8 sequence, mbtowc()ing it and
finally addch():n the wchar_t is right. When ncurses 5.3 is compiled 
used --with-widec it seems like sizeof(chtype) == sizeof(wchar_t) so
I see no fundamental flaw in above program.

Please correct me. 

--
Antti J�rvinen
e-mail: [EMAIL PROTECTED]
--
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/linux-utf8/

Reply via email to