1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-01 04:14:16 -04:00

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
This commit is contained in:
Valentin Batz 2005-07-24 19:16:14 +00:00 committed by vb
parent 547065cb42
commit 56041a3144
2 changed files with 17 additions and 10 deletions

View File

@ -4,14 +4,15 @@
RECODE RECODE
%|List the conversion database %|List the conversion database
RECODE ADD %|[[<tag>/]<target>] <charset> RECODE ADD %|<tag>|[<tag>/]<target>] <charset>
%|Add an entry to the conversion database (if target is omitted, %|Add an entry to the conversion database (if tag or target is
the current channel or query will be used). You can specify the omitted, the current channel or query will be used). You can specify
<tag> to have different charsets for the same <target> for the <tag> to have different charsets for the same <target> for
different networks. different networks. You can omit the target, and specify only the tag
if you want to add an entry for the network.
RECODE REMOVE %|[<target>] RECODE REMOVE %|[<tag>|<target>]
%|Remove an entry from the conversion database (if target is %|Remove an entry from the conversion database (if tag or target is
omitted, the current channel or query will be used) omitted, the current channel or query will be used)
To specify your local charset you have to set term_charset To specify your local charset you have to set term_charset

View File

@ -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); str_is_utf8 = g_utf8_validate(str, len, NULL);
translit = settings_get_bool("recode_transliterate"); translit = settings_get_bool("recode_transliterate");
if (server != NULL) if (server != 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);
if (tagtarget != NULL) if (tagtarget != NULL)
from = iconfig_get_str("conversions", tagtarget, NULL); from = iconfig_get_str("conversions", tagtarget, NULL);
g_free(tagtarget); g_free(tagtarget);
if (target != NULL && from == NULL) if (target != NULL && from == NULL)
from = iconfig_get_str("conversions", target, 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); 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);
if (from) 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 (!recoded) {
if (term_is_utf8) { if (term_is_utf8) {
@ -114,7 +118,7 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target)
from = "UTF-8"; from = "UTF-8";
if (from) 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 (!recoded)
recoded = g_strdup(str); recoded = g_strdup(str);
@ -158,6 +162,8 @@ char *recode_out(const SERVER_REC *server, const char *str, const char *target)
g_free(tagtarget); g_free(tagtarget);
if (to == NULL || *to == '\0') if (to == NULL || *to == '\0')
to = iconfig_get_str("conversions", target, NULL); 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') 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");