*** ncurses-5.4.orig/menu/m_item_new.c Sat Oct 25 17:23:42 2003 --- ncurses-5.4/menu/m_item_new.c Mon Apr 19 01:08:10 2004 *************** *** 53,64 **** --- 53,69 ---- static bool Is_Printable_String(const char *s) { assert(s); + #ifndef USE_WIDEC_SUPPORT + /* Do not actually perform a check for printability for the WIDEC + version, as it will fail with UTF-8 encoded characters */ + while(*s) { if (!isprint((unsigned char)*s)) return FALSE; s++; } + #endif return TRUE; } *** ncurses-5.4.orig/menu/m_post.c Sat Oct 25 16:54:48 2003 --- ncurses-5.4/menu/m_post.c Mon Apr 19 01:13:16 2004 *************** *** 48,53 **** --- 48,72 ---- | | Return Values : - +--------------------------------------------------------------------------*/ + + static size_t strlen_utf8(const char* s) + { + /* Calculate the correct length of characters in an UTF-8 encoded + string. The regular strlen function will merely report the + number of bytes used for encoding the string. */ + + unsigned char c; + size_t len = 0; + + while (c = *s++) { + if ((c & 0xC0) != 0x80) + ++len; + } + + return len; + } + + NCURSES_EXPORT(void) _nc_Post_Item (const MENU * menu, const ITEM * item) { *************** *** 56,64 **** int item_x, item_y; int count = 0; bool isfore = FALSE, isback=FALSE, isgrey = FALSE; ! assert(menu->win); ! getyx(menu->win,item_y,item_x); /* We need a marker iff --- 75,84 ---- int item_x, item_y; int count = 0; bool isfore = FALSE, isback=FALSE, isgrey = FALSE; ! int name_len, desc_len; ! assert(menu->win); ! getyx(menu->win,item_y,item_x); /* We need a marker iff *************** *** 117,123 **** } waddnstr(menu->win,item->name.str,item->name.length); ! for(ch=' ',i=menu->namelen-item->name.length;i>0;i--) { waddch(menu->win,ch); } --- 137,148 ---- } waddnstr(menu->win,item->name.str,item->name.length); ! #ifdef USE_WIDEC_SUPPORT ! name_len = strlen_utf8(item->name.str); ! #else ! name_len = item->name.len; ! #endif ! for(ch=' ', i=menu->namelen - name_len; i>0; i--) { waddch(menu->win,ch); } *************** *** 141,147 **** } if (item->description.length) waddnstr(menu->win,item->description.str,item->description.length); ! for(ch=' ',i=menu->desclen-item->description.length; i>0; i--) { waddch(menu->win,ch); } --- 166,177 ---- } if (item->description.length) waddnstr(menu->win,item->description.str,item->description.length); ! #ifdef USE_WIDEC_SUPPORT ! desc_len = strlen_utf8(item->description.str); ! #else ! desc_len = item->description.len; ! #endif ! for(ch=' ', i=menu->desclen - desc_len; i>0; i--) { waddch(menu->win,ch); }