diff libpurple/protocols/irc/parse.c @ 23639:aac5753e2528

This adds an "auto-detect UTF-8" option to IRC which, when enabled, will treat any incoming text which validates as UTF-8 as UTF-8 regardless of the configured account encoding. It does not affect transmission, and is not enabled by default (as it interferes with some non-UTF-8 encodings, notably ISO-2022).
author Ethan Blanton <elb@pidgin.im>
date Sun, 27 Jul 2008 13:29:26 +0000
parents dc359ea9eb9a
children c204239bef48 b522393714d6
line wrap: on
line diff
--- a/libpurple/protocols/irc/parse.c	Fri Jul 25 16:33:24 2008 +0000
+++ b/libpurple/protocols/irc/parse.c	Sun Jul 27 13:29:26 2008 +0000
@@ -253,6 +253,7 @@
 	char *utf8 = NULL;
 	const gchar *charset, *enclist;
 	gchar **encodings;
+	gboolean autodetect;
 	int i;
 
 	enclist = purple_account_get_string(irc->account, "encoding", IRC_DEFAULT_CHARSET);
@@ -263,6 +264,12 @@
 		return purple_utf8_salvage(string);
 	}
 
+	autodetect = purple_account_get_bool(irc->account, "autodetect_utf8", IRC_DEFAULT_AUTODETECT);
+
+	if (autodetect && g_utf8_validate(string, -1, NULL)) {
+		return g_strdup(string);
+	}
+
 	for (i = 0; encodings[i] != NULL; i++) {
 		charset = encodings[i];
 		while (*charset == ' ')