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:
parent
1b99b57e4f
commit
cce9683658
@ -52,10 +52,8 @@ static gboolean is_translit(const char *charset)
|
|||||||
|
|
||||||
gboolean is_valid_charset(const char *charset)
|
gboolean is_valid_charset(const char *charset)
|
||||||
{
|
{
|
||||||
const char *from="UTF-8";
|
GIConv cd;
|
||||||
const char *str="irssi";
|
char *to = NULL;
|
||||||
char *recoded, *to = NULL;
|
|
||||||
gboolean valid;
|
|
||||||
|
|
||||||
if (!charset || *charset == '\0')
|
if (!charset || *charset == '\0')
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -63,11 +61,13 @@ gboolean is_valid_charset(const char *charset)
|
|||||||
if (settings_get_bool("recode_transliterate") && !is_translit(charset))
|
if (settings_get_bool("recode_transliterate") && !is_translit(charset))
|
||||||
charset = to = g_strconcat(charset, "//TRANSLIT", NULL);
|
charset = to = g_strconcat(charset, "//TRANSLIT", NULL);
|
||||||
|
|
||||||
recoded = g_convert(str, strlen(str), charset, from, NULL, NULL, NULL);
|
cd = g_iconv_open(charset, "UTF-8");
|
||||||
valid = (recoded != NULL);
|
|
||||||
g_free(recoded);
|
|
||||||
g_free(to);
|
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)
|
static char *find_conversion(const SERVER_REC *server, const char *target)
|
||||||
|
Loading…
Reference in New Issue
Block a user