============================================================ --- libpurple/protocols/silc/ops.c 30ab18780af11a53b6564a44c4e8ebfc1a296d78 +++ libpurple/protocols/silc/ops.c 80bd9a7d3faf9e5ef28438647159fe19847e9839 @@ -408,9 +408,16 @@ silc_private_message(SilcClient client, } if (flags & SILC_MESSAGE_FLAG_UTF8) { - tmp = g_markup_escape_text((const char *)message, -1); + const char *msg = (const char *)message; + char *salvaged = NULL; + if (!g_utf8_validate((const char *)message, -1, NULL)) { + salvaged = purple_utf8_salvage((const char *)message); + msg = salvaged; + } + tmp = g_markup_escape_text(msg, -1); /* Send to Purple */ serv_got_im(gc, sender->nickname, tmp, 0, time(NULL)); + g_free(salvaged); g_free(tmp); } }