Server line text-encoding-related fixes.

- Handle server lines that contain sequences which are invalid in the server encoding. Previously, these would cause the whole line to be interpreted in ISO-8859-1, but now they're simply replaced with an appropriate replacement character.

- Removed prefs.utf8_locale.

- Change default server encoding from system locale to UTF-8.

- Always populate server->encoding with a non-null value - UTF-8.

Fixes #1198
This commit is contained in:
Arnavion
2015-01-18 02:10:04 -08:00
parent 5569205d15
commit 5749c53484
7 changed files with 129 additions and 326 deletions

View File

@@ -505,29 +505,11 @@ dcc_chat_line (struct DCC *dcc, char *line)
session *sess;
char *word[PDIWORDS];
char *po;
char *utf;
char *conv;
int ret, i;
gssize len;
gsize utf_len;
char portbuf[32];
message_tags_data no_tags = MESSAGE_TAGS_DATA_INIT;
len = strlen (line);
if (dcc->serv->encoding == NULL) /* system */
utf = g_locale_to_utf8 (line, len, NULL, &utf_len, NULL);
else
utf = g_convert (line, len, "UTF-8", dcc->serv->encoding, 0, &utf_len, 0);
if (utf)
{
line = utf;
len = utf_len;
}
/* we really need valid UTF-8 now */
conv = text_validate (&line, &len);
line = text_invalid_encoding_to_utf8 (line, -1, dcc->serv->encoding, NULL);
sess = find_dialog (dcc->serv, dcc->nick);
if (!sess)
@@ -548,16 +530,14 @@ dcc_chat_line (struct DCC *dcc, char *line)
/* did the plugin close it? */
if (!g_slist_find (dcc_list, dcc))
{
g_free (utf);
g_free (conv);
g_free (line);
return 1;
}
/* did the plugin eat the event? */
if (ret)
{
g_free (utf);
g_free (conv);
g_free (line);
return 0;
}
@@ -574,8 +554,7 @@ dcc_chat_line (struct DCC *dcc, char *line)
{
inbound_privmsg (dcc->serv, dcc->nick, "", line, FALSE, &no_tags);
}
g_free (utf);
g_free (conv);
g_free (line);
return 0;
}