summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorValentin Batz <senneth@irssi.org>2005-07-24 19:16:14 +0000
committervb <vb@dbcabf3a-b0e7-0310-adc4-f8d773084564>2005-07-24 19:16:14 +0000
commit56041a314402b93835ce26e8a4d1e49db34e0c72 (patch)
tree7ba704af067c10e19362497595a8182528b15574 /src
parent547065cb42de5122baabaee9bd7fef1cf30382eb (diff)
downloadirssi-56041a314402b93835ce26e8a4d1e49db34e0c72.zip
Added an option to specify a charset for a whole network. For example /recode add IRCnet iso-8859-1 (http://bugs.irssi.org/index.php?do=details&id=284) Patch by Sergey Safonov. Replaced g_convert by g_convert_with_fallback in recode_in (http://bugs.irssi.org/index.php?do=details&id=241) Patch by Kuang-che Wu.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3881 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/core/recode.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/core/recode.c b/src/core/recode.c
index 353d8ed2..b3668ed0 100644
--- a/src/core/recode.c
+++ b/src/core/recode.c
@@ -87,23 +87,27 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target)
str_is_utf8 = g_utf8_validate(str, len, NULL);
translit = settings_get_bool("recode_transliterate");
-
+
if (server != NULL)
tagtarget = server->tag == NULL ? NULL :
g_strdup_printf("%s/%s", server->tag, target);
if (tagtarget != NULL)
from = iconfig_get_str("conversions", tagtarget, NULL);
g_free(tagtarget);
+
if (target != NULL && from == NULL)
from = iconfig_get_str("conversions", target, NULL);
+ if (from == NULL)
+ from = iconfig_get_str("conversions", server->tag, NULL);
+
term_is_utf8 = recode_get_charset(&to);
if (translit && !is_translit(to))
to = translit_to = g_strconcat(to, "//TRANSLIT", NULL);
if (from)
- recoded = g_convert(str, len, to, from, NULL, NULL, NULL);
+ recoded = g_convert_with_fallback(str, len, to, from, NULL, NULL, NULL);
if (!recoded) {
if (term_is_utf8) {
@@ -114,7 +118,7 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target)
from = "UTF-8";
if (from)
- recoded = g_convert(str, len, to, from, NULL, NULL, NULL);
+ recoded = g_convert_with_fallback(str, len, to, from, NULL, NULL, NULL);
if (!recoded)
recoded = g_strdup(str);
@@ -159,6 +163,8 @@ char *recode_out(const SERVER_REC *server, const char *str, const char *target)
if (to == NULL || *to == '\0')
to = iconfig_get_str("conversions", target, NULL);
if (to == NULL || *to == '\0')
+ to = iconfig_get_str("conversions", server->tag, NULL);
+ if (to == NULL || *to == '\0')
/* default outgoing charset if set */
to = settings_get_str("recode_out_default_charset");