Mercurial > pidgin
changeset 23594: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 | 1b7dea5ce0cd |
children | b33b5e56a482 |
files | ChangeLog libpurple/protocols/irc/irc.c libpurple/protocols/irc/irc.h libpurple/protocols/irc/parse.c |
diffstat | 4 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Jul 25 16:33:24 2008 +0000 +++ b/ChangeLog Sun Jul 27 13:29:26 2008 +0000 @@ -12,6 +12,8 @@ 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
--- a/libpurple/protocols/irc/irc.c Fri Jul 25 16:33:24 2008 +0000 +++ b/libpurple/protocols/irc/irc.c Sun Jul 27 13:29:26 2008 +0000 @@ -989,6 +989,9 @@ 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);
--- a/libpurple/protocols/irc/irc.h Fri Jul 25 16:33:24 2008 +0000 +++ b/libpurple/protocols/irc/irc.h Sun Jul 27 13:29:26 2008 +0000 @@ -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."
--- 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 == ' ')