[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
form_driver and wide-char
From: |
Brian Tan |
Subject: |
form_driver and wide-char |
Date: |
Wed, 06 Dec 2006 15:00:13 -0500 |
User-agent: |
Thunderbird 1.5.0.8 (X11/20061107) |
Hi
I am trying to use form_driver with utf8 Chinese input. It seems that
form_driver (FC6 ncurses-devel-5.5-24.20060715 FC6) not supporting
wide-char (yet?). So I tried wctomb and append field_buffer with mbs and
set_field_buffer. Field buffer displayed OK except for spacing problem
after the Chinese char (diff between strlen and wcwidth, I think).
However, reading buffer with field_buffer, the Chinese char became
garbled. Code fragment as follows (linked with ncursesw and formw).
Question: is there or will there be a "wide" version of form_driver ? If
not, what is the best way of handling wide characters?
setlocale(LC_ALL,"");
int retc;
wchar_t wch;
retc = get_wch(&wch);
switch (retc) {
case KEY_CODE_YES: // function keys
switch (wch) {
case KEY_XXX:
form_driver(my_form, REQ_YYY);
break;
.....
}
case OK: // wchar
int len;
char mbs[10];
len = wctomb(mbs,wch);
mbs[len] = '\0';
int fld; char buff[256]; char *ptr;
fld = field_index(current_field(my_form));
form_driver(my_form, REQ_VALIDATION);
strcpy(buff, field_buffer(field[fld],0));
ptr = buff + strlen(buff); // trim trailing spaces
mvprintw(23,0,"b/f buff=%s= ", buff); // debug
while (--ptr && *ptr == ' ' && ptr >= buff);
*ptr = '\0';
if (wch < 128) {
form_driver(my_form, wch);
} else {
strncat(buff, mbs, len);
set_field_buffer(field[fld],0,buff);
mvprintw(24,0,"a/f buff=%s= ", buff); // debug
}
break;
}
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
- form_driver and wide-char,
Brian Tan <=
- Re: form_driver and wide-char, Thomas Dickey, 2006/12/06
- Re: form_driver and wide-char, Brian Tan, 2006/12/06
- Re: form_driver and wide-char, Thomas Dickey, 2006/12/06
- Re: form_driver and wide-char, Brian Tan, 2006/12/06
- Re: form_driver and wide-char, Thomas Dickey, 2006/12/07
- Re: form_driver and wide-char, Brian Tan, 2006/12/07
- Re: form_driver and wide-char, Thomas Dickey, 2006/12/07
- Re: form_driver and wide-char, Brian Tan, 2006/12/08
- Re: form_driver and wide-char, Thomas Dickey, 2006/12/07