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
This commit is contained in:
Valentin Batz 2005-11-07 19:06:42 +00:00 committed by vb
parent db7e667770
commit 68e4516d0b
2 changed files with 31 additions and 21 deletions

View File

@ -50,6 +50,9 @@ The transliteration is based on your locale settings,
if it doesn't work properly your locale settings may be wrong. if it doesn't work properly your locale settings may be wrong.
You can enable it per target by adding //TRANSLIT to the <charset> 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' Hint: <charset> can be almost everything listed by 'iconv -l'
See also: NETWORK See also: NETWORK

View File

@ -73,7 +73,7 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target)
char *translit_to = NULL; char *translit_to = NULL;
char *recoded = NULL; char *recoded = NULL;
char *tagtarget = 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; int len;
if (!str) if (!str)
@ -87,7 +87,16 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target)
str_is_utf8 = g_utf8_validate(str, len, NULL); str_is_utf8 = g_utf8_validate(str, len, NULL);
translit = settings_get_bool("recode_transliterate"); translit = settings_get_bool("recode_transliterate");
autodetect = settings_get_bool("recode_autodetect_utf8");
term_is_utf8 = recode_get_charset(&to);
if (autodetect && str_is_utf8)
if (term_is_utf8)
return g_strdup(str);
else
from = "UTF-8";
else {
if (server != NULL && target != NULL) if (server != NULL && target != NULL)
tagtarget = server->tag == NULL ? NULL : tagtarget = server->tag == NULL ? NULL :
g_strdup_printf("%s/%s", server->tag, target); g_strdup_printf("%s/%s", server->tag, target);
@ -101,7 +110,7 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target)
if (from == NULL && server != NULL) if (from == NULL && server != NULL)
from = iconfig_get_str("conversions", server->tag, NULL); from = iconfig_get_str("conversions", server->tag, NULL);
term_is_utf8 = recode_get_charset(&to); }
if (translit && !is_translit(to)) if (translit && !is_translit(to))
to = translit_to = g_strconcat(to, "//TRANSLIT", NULL); to = translit_to = g_strconcat(to, "//TRANSLIT", NULL);
@ -189,15 +198,13 @@ char *recode_out(const SERVER_REC *server, const char *str, const char *target)
void recode_init(void) void recode_init(void)
{ {
settings_add_bool("misc", "recode", TRUE); 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_str("misc", "recode_out_default_charset", "");
settings_add_bool("misc", "recode_transliterate", FALSE); settings_add_bool("misc", "recode_transliterate", FALSE);
settings_add_bool("misc", "recode_autodetect_utf8", TRUE);
} }
void recode_deinit(void) void recode_deinit(void)
{ {
settings_remove("recode");
settings_remove("recode_fallback");
settings_remove("recode_out_default_charset");
settings_remove("recode_transliterate");
} }