diff options
author | Valentin Batz <senneth@irssi.org> | 2005-11-07 19:06:42 +0000 |
---|---|---|
committer | vb <vb@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2005-11-07 19:06:42 +0000 |
commit | 68e4516d0b102d1119fdc95b6f5184c01d4d1d47 (patch) | |
tree | 3a7c7bfec40fde12cb053da8d6c7f342016a2503 | |
parent | db7e6677709244650540d3e173958b19d3fcc5c4 (diff) | |
download | irssi-68e4516d0b102d1119fdc95b6f5184c01d4d1d47.zip |
changed recode_fallback to CP1252
added recode_autodetect_utf8, it's on by default
removed settings_remove calls from recode_deinit since I don't see any other internal module doing it
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4067 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | docs/help/in/recode.in | 3 | ||||
-rw-r--r-- | src/core/recode.c | 45 |
2 files changed, 29 insertions, 19 deletions
diff --git a/docs/help/in/recode.in b/docs/help/in/recode.in index 4aaa8e52..8801c565 100644 --- a/docs/help/in/recode.in +++ b/docs/help/in/recode.in @@ -50,6 +50,9 @@ The transliteration is based on your locale settings, if it doesn't work properly your locale settings may be wrong. You can enable it per target by adding //TRANSLIT to the <charset> +/SET recode_autodetect_utf8 OFF +to turn automatic UTF-8 detection off. + Hint: <charset> can be almost everything listed by 'iconv -l' See also: NETWORK diff --git a/src/core/recode.c b/src/core/recode.c index fbc17944..8266d843 100644 --- a/src/core/recode.c +++ b/src/core/recode.c @@ -73,7 +73,7 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target) char *translit_to = NULL; char *recoded = NULL; char *tagtarget = NULL; - gboolean term_is_utf8, str_is_utf8, translit, recode; + gboolean term_is_utf8, str_is_utf8, translit, recode, autodetect; int len; if (!str) @@ -87,25 +87,34 @@ 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 && target != 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); + autodetect = settings_get_bool("recode_autodetect_utf8"); + term_is_utf8 = recode_get_charset(&to); - if (target != NULL && from == NULL) - from = iconfig_get_str("conversions", target, NULL); + if (autodetect && str_is_utf8) + if (term_is_utf8) + return g_strdup(str); + else + from = "UTF-8"; + + else { + if (server != NULL && target != 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 (from == NULL && server != NULL) - from = iconfig_get_str("conversions", server->tag, NULL); + if (target != NULL && from == NULL) + from = iconfig_get_str("conversions", target, NULL); - term_is_utf8 = recode_get_charset(&to); + if (from == NULL && server != NULL) + from = iconfig_get_str("conversions", server->tag, NULL); + + } if (translit && !is_translit(to)) to = translit_to = g_strconcat(to, "//TRANSLIT", NULL); - + if (from) recoded = g_convert_with_fallback(str, len, to, from, NULL, NULL, NULL, NULL); @@ -189,15 +198,13 @@ char *recode_out(const SERVER_REC *server, const char *str, const char *target) void recode_init(void) { settings_add_bool("misc", "recode", TRUE); - settings_add_str("misc", "recode_fallback", "ISO8859-1"); + settings_add_str("misc", "recode_fallback", "CP1252"); settings_add_str("misc", "recode_out_default_charset", ""); settings_add_bool("misc", "recode_transliterate", FALSE); + settings_add_bool("misc", "recode_autodetect_utf8", TRUE); } void recode_deinit(void) { - settings_remove("recode"); - settings_remove("recode_fallback"); - settings_remove("recode_out_default_charset"); - settings_remove("recode_transliterate"); + } |