summaryrefslogtreecommitdiffstats
path: root/iconv.c
diff options
context:
space:
mode:
Diffstat (limited to 'iconv.c')
-rw-r--r--iconv.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/iconv.c b/iconv.c
index 6fa63a7..b5a7f3d 100644
--- a/iconv.c
+++ b/iconv.c
@@ -43,12 +43,12 @@ struct converter supported_codesets[] = {
.encode = &encode_ascii,
}, {
.code = UTF_8,
- .name = "UTF-8",
+ .name = "UTF-8" "\0" "UTF8" "\0",
.decode = &decode_utf_8,
.encode = &encode_utf_8,
}, {
.code = ISO_8859_1,
- .name = "ISO-8859-1",
+ .name = "ISO-8859-1" "\0" "ISO8859-1" "\0",
.decode = &decode_iso_8859_1,
.encode = &encode_iso_8859_1
}, {
@@ -151,6 +151,16 @@ static void toupperstr(char *p)
}
}
+static int is_codeset(const char *str, const char *list)
+{
+ while (*list) {
+ if (strcmp(str, list) == 0)
+ return 1;
+ list += strlen(list) + 1;
+ }
+ return 0;
+}
+
static int find_converter(const char *str)
{
int i;
@@ -159,7 +169,7 @@ static int find_converter(const char *str)
buf[15] = '\0';
toupperstr(buf);
for (i = 0; supported_codesets[i].code != -1; i++) {
- if (strcmp(buf, supported_codesets[i].name) == 0)
+ if (is_codeset(buf, supported_codesets[i].name))
return i;
}
return -1;