comparison 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
comparison
equal deleted inserted replaced
23638:1b7dea5ce0cd 23639:aac5753e2528
251 static char *irc_recv_convert(struct irc_conn *irc, const char *string) 251 static char *irc_recv_convert(struct irc_conn *irc, const char *string)
252 { 252 {
253 char *utf8 = NULL; 253 char *utf8 = NULL;
254 const gchar *charset, *enclist; 254 const gchar *charset, *enclist;
255 gchar **encodings; 255 gchar **encodings;
256 gboolean autodetect;
256 int i; 257 int i;
257 258
258 enclist = purple_account_get_string(irc->account, "encoding", IRC_DEFAULT_CHARSET); 259 enclist = purple_account_get_string(irc->account, "encoding", IRC_DEFAULT_CHARSET);
259 encodings = g_strsplit(enclist, ",", -1); 260 encodings = g_strsplit(enclist, ",", -1);
260 261
261 if (encodings[0] == NULL) { 262 if (encodings[0] == NULL) {
262 g_strfreev(encodings); 263 g_strfreev(encodings);
263 return purple_utf8_salvage(string); 264 return purple_utf8_salvage(string);
265 }
266
267 autodetect = purple_account_get_bool(irc->account, "autodetect_utf8", IRC_DEFAULT_AUTODETECT);
268
269 if (autodetect && g_utf8_validate(string, -1, NULL)) {
270 return g_strdup(string);
264 } 271 }
265 272
266 for (i = 0; encodings[i] != NULL; i++) { 273 for (i = 0; encodings[i] != NULL; i++) {
267 charset = encodings[i]; 274 charset = encodings[i];
268 while (*charset == ' ') 275 while (*charset == ' ')