1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Simplify is_valid_charset by just checking with g_iconv_open that the

conversion is supported.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4665 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Emanuele Giaquinta 2007-12-09 16:10:07 +00:00 committed by exg
parent 1b99b57e4f
commit cce9683658

View File

@ -52,10 +52,8 @@ static gboolean is_translit(const char *charset)
gboolean is_valid_charset(const char *charset)
{
const char *from="UTF-8";
const char *str="irssi";
char *recoded, *to = NULL;
gboolean valid;
GIConv cd;
char *to = NULL;
if (!charset || *charset == '\0')
return FALSE;
@ -63,11 +61,13 @@ gboolean is_valid_charset(const char *charset)
if (settings_get_bool("recode_transliterate") && !is_translit(charset))
charset = to = g_strconcat(charset, "//TRANSLIT", NULL);
recoded = g_convert(str, strlen(str), charset, from, NULL, NULL, NULL);
valid = (recoded != NULL);
g_free(recoded);
cd = g_iconv_open(charset, "UTF-8");
g_free(to);
return valid;
if (cd != (GIConv)-1) {
g_iconv_close(cd);
return TRUE;
}
return FALSE;
}
static char *find_conversion(const SERVER_REC *server, const char *target)