1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-27 05:20:20 -04:00

Changed the order of recode_out_default_charset, it doesn't override /recode add anymore. The string returned by nl_langinfo(CODESET) may be empty, use ISO8859-1 in this case

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3306 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Valentin Batz 2004-09-20 12:45:49 +00:00 committed by senneth
parent 4cc4ddc1a7
commit a26038c664
4 changed files with 20 additions and 16 deletions

View File

@ -27,15 +27,15 @@ Examples:
/SET recode_fallback <charset> /SET recode_fallback <charset>
to set the fallback charset for incoming events to set the fallback charset for incoming events
This charset will be used when a conversion to This charset is used if your term_charset is UTF-8
the defined charset(/recode add) fails or if the and the conversion for the target is not set and
charset for the target(query or channel) is not set. the text is not UTF-8.
/SET recode_out_default_charset <charset> /SET recode_out_default_charset <charset>
to set the global outgoing charset to set the global outgoing charset
When it's set to a charset it will be used instead When it's set to a charset it will be used
of the charset you have defined with /recode add if no conversion for the target is set.
/SET recode_transliterate ON /SET recode_transliterate ON
to enable the global transliteration. to enable the global transliteration.

View File

@ -76,14 +76,14 @@ char *recode_in(const char *str, const char *target)
int len; int len;
if (!str) if (!str)
return g_strdup(str); return NULL;
len = strlen(str); len = strlen(str);
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");
if (target != NULL && from == NULL) if (target != NULL)
from = iconfig_get_str("conversions", target, NULL); from = iconfig_get_str("conversions", target, NULL);
term_is_utf8 = recode_get_charset(&to); term_is_utf8 = recode_get_charset(&to);
@ -120,12 +120,11 @@ char *recode_out(const char *str, const char *target)
#ifdef HAVE_GLIB2 #ifdef HAVE_GLIB2
char *recoded = NULL; char *recoded = NULL;
const char *from = NULL; const char *from = NULL;
gboolean translit; gboolean translit, term_is_utf8;
gboolean term_is_utf8;
int len; int len;
if (!str) if (!str)
return g_strdup(str); return NULL;
len = strlen(str); len = strlen(str);
@ -135,10 +134,11 @@ char *recode_out(const char *str, const char *target)
const char *to = NULL; const char *to = NULL;
char *translit_to = NULL; char *translit_to = NULL;
to = iconfig_get_str("conversions", target, NULL);
if (to == NULL || *to == '\0')
/* default outgoing charset if set */ /* default outgoing charset if set */
to = settings_get_str("recode_out_default_charset"); to = settings_get_str("recode_out_default_charset");
if (to == NULL || *to == '\0')
to = iconfig_get_str("conversions", target, NULL);
if (to && *to != '\0') { if (to && *to != '\0') {
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);

View File

@ -175,7 +175,9 @@ void fe_common_core_init(void)
settings_add_bool("lookandfeel", "use_status_window", TRUE); settings_add_bool("lookandfeel", "use_status_window", TRUE);
settings_add_bool("lookandfeel", "use_msgs_window", FALSE); settings_add_bool("lookandfeel", "use_msgs_window", FALSE);
#if defined (HAVE_NL_LANGINFO) && defined(CODESET) #if defined (HAVE_NL_LANGINFO) && defined(CODESET)
settings_add_str("lookandfeel", "term_charset", nl_langinfo(CODESET)); settings_add_str("lookandfeel", "term_charset",
*nl_langinfo(CODESET) != '\0' ?
nl_langinfo(CODESET) : "ISO8859-1");
#else #else
settings_add_str("lookandfeel", "term_charset", "ISO8859-1"); settings_add_str("lookandfeel", "term_charset", "ISO8859-1");
#endif #endif

View File

@ -165,7 +165,9 @@ static void read_settings(void)
term_charset = settings_get_str("term_charset"); term_charset = settings_get_str("term_charset");
if (!is_valid_charset(term_charset)) { if (!is_valid_charset(term_charset)) {
#if defined (HAVE_NL_LANGINFO) && defined(CODESET) #if defined (HAVE_NL_LANGINFO) && defined(CODESET)
settings_set_str("term_charset", is_valid_charset(old_term_charset) ? old_term_charset : nl_langinfo(CODESET)); settings_set_str("term_charset", is_valid_charset(old_term_charset) ?
old_term_charset : *nl_langinfo(CODESET) != '\0' ?
nl_langinfo(CODESET) : "ISO8859-1");
#else #else
settings_set_str("term_charset", is_valid_charset(old_term_charset) ? old_term_charset : "ISO8859-1"); settings_set_str("term_charset", is_valid_charset(old_term_charset) ? old_term_charset : "ISO8859-1");
#endif #endif