X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=menu.c;h=15eccce1f5006a4d795bf71981cdf7635dbf5898;hp=35a49879fd7b67a19dd89f97a93b5f2eb09697b5;hb=4ff362c6b720c1ae7c6fde8300567644905bd923;hpb=f404a0ca916be07049af51a3022baaaaab94def6 diff --git a/menu.c b/menu.c index 35a4987..15eccce 100644 --- a/menu.c +++ b/menu.c @@ -39,9 +39,12 @@ extern size_t UngetCount; static void print_enriched_string (int attr, unsigned char *s, int do_color) { + wchar_t wc; size_t k; size_t n = mutt_strlen ((char *)s); + mbstate_t mbstate; + memset (&mbstate, 0, sizeof (mbstate)); while (*s) { if (*s < M_TREE_MAX) @@ -131,10 +134,10 @@ static void print_enriched_string (int attr, unsigned char *s, int do_color) } if (do_color) attrset(attr); } - else if (*s > 0) + else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0) { - addnstr ((char *)s, 1); - s += 1, n-= 1; + addnstr ((char *)s, k); + s += k, n-= k; } else break; @@ -157,8 +160,12 @@ void menu_pad_string (char *s, size_t n) int shift = option (OPTARROWCURSOR) ? 3 : 0; int cols = COLS - shift - SidebarWidth; - mutt_format_string (s, n, cols, cols, 0, ' ', s, strlen (s), 1); - s[n - 1] = 0; + char tmpbuf[n]; + + mutt_format_string (tmpbuf, n, cols, cols, 0, ' ', s, strlen (s), 1); + tmpbuf[n - 1] = 0; + + snprintf(s,n,"%s",tmpbuf); /* overkill */ } void menu_redraw_full (MUTTMENU *menu)