Fixes truncating utf-8 buddy names (Myhailo Danylenko)
This patch fixes the problem with utf-8 buddy names,
which include multibyte characters. Without patch names
will be decreased by as many extra bytes as we have in name.
Note by Mikael: When a non-UTF-8 locale is used, the conversion from
UTF-8 could fail, which gave a "(null)" buddy name.
--- a/mcabber/src/screen.c Sat Oct 21 11:22:15 2006 +0200
+++ b/mcabber/src/screen.c Sat Oct 21 15:00:41 2006 +0200
@@ -1169,7 +1169,7 @@
for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) {
unsigned short bflags, btype, ismsg, isgrp, ismuc, ishid, isspe;
- gchar *rline_locale;
+ gchar *name_locale;
bflags = buddy_getflags(BUDDATA(buddy));
btype = buddy_gettype(BUDDATA(buddy));
@@ -1221,8 +1221,9 @@
wattrset(rosterWnd, get_color(COLOR_ROSTER));
}
+ name_locale = from_utf8(buddy_getname(BUDDATA(buddy)));
if (Roster_Width > 7)
- strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7);
+ strncpy(name, name_locale, Roster_Width-7);
else
name[0] = 0;
@@ -1252,9 +1253,8 @@
" %c%c%c%c %s", pending, sepleft, status, sepright, name);
}
- rline_locale = from_utf8(rline);
- mvwprintw(rosterWnd, i, x_pos, "%s", rline_locale);
- g_free(rline_locale);
+ mvwprintw(rosterWnd, i, x_pos, "%s", rline);
+ g_free(name_locale);
i++;
}