GtkTextView *text = GTK_TEXT_VIEW(textview->text);
GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
GtkTextIter iter;
+ gchar *mybuf = g_strdup(linebuf);
+
+ if (!g_utf8_validate(linebuf, -1, NULL)) {
+ mybuf = g_malloc(strlen(linebuf)*2 +1);
+ conv_localetodisp(mybuf, strlen(linebuf)*2 +1, linebuf);
+ }
/* parse table - in order of priority */
struct table {
gtk_text_buffer_get_end_iter(buffer, &iter);
/* parse for clickable parts, and build a list of begin and end positions */
- for (walk = linebuf, n = 0;;) {
+ for (walk = mybuf, n = 0;;) {
gint last_index = PARSE_ELEMS;
gchar *scanpos = NULL;
/* colorize this line */
if (head.next) {
- const gchar *normal_text = linebuf;
+ const gchar *normal_text = mybuf;
/* insert URIs */
for (last = head.next; last != NULL;
(buffer, &iter, normal_text, -1, fg_tag, NULL);
} else {
gtk_text_buffer_insert_with_tags_by_name
- (buffer, &iter, linebuf, -1, fg_tag, NULL);
+ (buffer, &iter, mybuf, -1, fg_tag, NULL);
}
+ g_free(mybuf);
}
#undef ADD_TXT_POS
if (!conv)
strncpy2(buf, str, sizeof(buf));
else if (conv_convert(conv, buf, sizeof(buf), str) < 0)
- conv_utf8todisp(buf, sizeof(buf), str);
-
+ conv_localetodisp(buf, sizeof(buf), str);
+
strcrchomp(buf);
//if (prefs_common.conv_mb_alnum) conv_mb_alnum(buf);
fg_color = NULL;
/* convert to UTF-8 */
conv_str = conv_codeset_strdup(decoded_text, charset, NULL);
- if (!conv_str) {
+ if (!conv_str || !g_utf8_validate(conv_str, -1, NULL)) {
+ g_free(conv_str);
conv_str = g_malloc(len + 1);
conv_utf8todisp(conv_str, len + 1, decoded_text);
}