comparison mcabber/src/screen.c @ 980:023891f99732

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.
author Mikael Berthe <mikael@lilotux.net>
date Sat, 21 Oct 2006 15:00:41 +0200
parents e693cbe33802
children 553b8ecf901f
comparison
equal deleted inserted replaced
979:ea939ff047d8 980:023891f99732
1167 buddy = buddylist; 1167 buddy = buddylist;
1168 rOffset = offset; 1168 rOffset = offset;
1169 1169
1170 for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) { 1170 for (i=0; i<maxy && buddy; buddy = g_list_next(buddy)) {
1171 unsigned short bflags, btype, ismsg, isgrp, ismuc, ishid, isspe; 1171 unsigned short bflags, btype, ismsg, isgrp, ismuc, ishid, isspe;
1172 gchar *rline_locale; 1172 gchar *name_locale;
1173 1173
1174 bflags = buddy_getflags(BUDDATA(buddy)); 1174 bflags = buddy_getflags(BUDDATA(buddy));
1175 btype = buddy_gettype(BUDDATA(buddy)); 1175 btype = buddy_gettype(BUDDATA(buddy));
1176 1176
1177 ismsg = bflags & ROSTER_FLAG_MSG; 1177 ismsg = bflags & ROSTER_FLAG_MSG;
1219 wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG)); 1219 wattrset(rosterWnd, get_color(COLOR_ROSTERNMSG));
1220 else 1220 else
1221 wattrset(rosterWnd, get_color(COLOR_ROSTER)); 1221 wattrset(rosterWnd, get_color(COLOR_ROSTER));
1222 } 1222 }
1223 1223
1224 name_locale = from_utf8(buddy_getname(BUDDATA(buddy)));
1224 if (Roster_Width > 7) 1225 if (Roster_Width > 7)
1225 strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7); 1226 strncpy(name, name_locale, Roster_Width-7);
1226 else 1227 else
1227 name[0] = 0; 1228 name[0] = 0;
1228 1229
1229 if (isgrp) { 1230 if (isgrp) {
1230 char *sep; 1231 char *sep;
1250 1251
1251 snprintf(rline, Roster_Width, 1252 snprintf(rline, Roster_Width,
1252 " %c%c%c%c %s", pending, sepleft, status, sepright, name); 1253 " %c%c%c%c %s", pending, sepleft, status, sepright, name);
1253 } 1254 }
1254 1255
1255 rline_locale = from_utf8(rline); 1256 mvwprintw(rosterWnd, i, x_pos, "%s", rline);
1256 mvwprintw(rosterWnd, i, x_pos, "%s", rline_locale); 1257 g_free(name_locale);
1257 g_free(rline_locale);
1258 i++; 1258 i++;
1259 } 1259 }
1260 1260
1261 g_free(rline); 1261 g_free(rline);
1262 g_free(name); 1262 g_free(name);