summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorEmanuele Giaquinta <exg@irssi.org>2007-12-09 16:10:07 +0000
committerexg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564>2007-12-09 16:10:07 +0000
commitcce9683658d89b7b2b5cd5ab5ca598b3627bb1ec (patch)
tree9065eff701a038021946f76cd398dadd71478736 /src/core
parent1b99b57e4fcb91809abef72bae968b59142b086a (diff)
downloadirssi-cce9683658d89b7b2b5cd5ab5ca598b3627bb1ec.zip
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
Diffstat (limited to 'src/core')
-rw-r--r--src/core/recode.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/recode.c b/src/core/recode.c
index a2ff2e26..77ae10c5 100644
--- a/src/core/recode.c
+++ b/src/core/recode.c
@@ -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)