pidgin: 48377678: This adds an "auto-detect UTF-8" option ...

elb at pidgin.im elb at pidgin.im
Fri Aug 1 15:50:49 EDT 2008


-----------------------------------------------------------------
Revision: 4837767868c0defe45efc50e8d0639be2ed4ad7d
Ancestor: a1515f71238597d861299c4a998b98967c1d6ef9
Author: elb at pidgin.im
Date: 2008-07-27T13:29:26
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4837767868c0defe45efc50e8d0639be2ed4ad7d

Modified files:
        ChangeLog libpurple/protocols/irc/irc.c
        libpurple/protocols/irc/irc.h
        libpurple/protocols/irc/parse.c

ChangeLog: 

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).

-------------- next part --------------
============================================================
--- ChangeLog	dc61c0d07ba9d758b05c31428028d0a6fb6c6afa
+++ ChangeLog	cf74aa76727c24dcf3f5881076152570d9ccf58d
@@ -12,6 +12,8 @@ version 2.5.0 (??/??/2008):
 
 	IRC:
 	* /ctcp command (Vladislav Guberinić)
+	* Allow for auto-detection of incoming UTF-8 formatted text on
+	  accounts which are configured to use some other encoding.
 
 	MSN:
 	* Update MSN support to protocol 15 (Elliott Sales de Andrade, Jorge
============================================================
--- libpurple/protocols/irc/irc.c	afe1bb6f873de92dd1aca7288273ccc146b3b29e
+++ libpurple/protocols/irc/irc.c	72232dd16f455e0ce3b0e0e11f7ae31041a40a48
@@ -989,6 +989,9 @@ static void _init_plugin(PurplePlugin *p
 	option = purple_account_option_string_new(_("Encodings"), "encoding", IRC_DEFAULT_CHARSET);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 
+	option = purple_account_option_bool_new(_("Auto-detect incoming UTF-8"), "autodetect_utf8", IRC_DEFAULT_AUTODETECT);
+	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
+
 	option = purple_account_option_string_new(_("Username"), "username", "");
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 
============================================================
--- libpurple/protocols/irc/irc.h	f10942383ebaf18501bdd3d60917ee05cbd4fb6f
+++ libpurple/protocols/irc/irc.h	cc71f26aa63145049ea700ea00260dc22d78c0fd
@@ -35,6 +35,7 @@
 #define IRC_DEFAULT_SSL_PORT 994
 
 #define IRC_DEFAULT_CHARSET "UTF-8"
+#define IRC_DEFAULT_AUTODETECT FALSE
 #define IRC_DEFAULT_ALIAS "purple"
 
 #define IRC_DEFAULT_QUIT "Leaving."
============================================================
--- libpurple/protocols/irc/parse.c	4d3663539911d5b6e9e14d203a091c8e37ed73c1
+++ libpurple/protocols/irc/parse.c	5b7ebf223c97705e602213f69c8d23e3f8f8c254
@@ -253,6 +253,7 @@ static char *irc_recv_convert(struct irc
 	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 @@ static char *irc_recv_convert(struct irc
 		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 == ' ')


More information about the Commits mailing list