From b6d1043499d87d579d8a3cfb422df9a688dbb15e Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Sat, 13 Oct 2001 02:29:25 +0000 Subject: Fix for Debian systems which apparently can use a ';' as a codeset 2001-10-12 Jeffrey Stedfast * gal/util/e-iconv.c (e_iconv_init): Fix for Debian systems which apparently can use a ';' as a codeset terminator? Cleaned up the code in the process, the parser is a little nicer now. svn path=/trunk/; revision=13650 --- e-util/e-iconv.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'e-util/e-iconv.c') diff --git a/e-util/e-iconv.c b/e-util/e-iconv.c index 77a7e0b8e6..99c6c888d5 100644 --- a/e-util/e-iconv.c +++ b/e-util/e-iconv.c @@ -225,17 +225,19 @@ e_iconv_init(int keep) * codeset is a character set or encoding identifier like * ISO-8859-1 or UTF-8. */ - char *p; - int len; + char *codeset, *p; - p = strchr (locale, '@'); - if (p == NULL) - p = strchr (locale, '/'); /* This is a hack for Solaris systems */ - - len = p ? (p - locale) : strlen (locale); - if ((p = strchr (locale, '.'))) { - locale_charset = g_strndup (p + 1, len - (p - locale) + 1); + codeset = strchr (locale, '.'); + if (codeset) { + codeset++; + + /* ; is a hack for debian systems and / is a hack for Solaris systems */ + for (p = codeset; *p && !strchr ("@;/", *p); p++); + locale_charset = g_strndup (codeset, p - codeset); g_strdown (locale_charset); + } else { + /* charset unknown */ + locale_charset = NULL; } #endif } @@ -327,8 +329,8 @@ iconv_t e_iconv_open(const char *oto, const char *ofrom) if (oto == NULL || ofrom == NULL) return (iconv_t)-1; - to = e_iconv_charset_name(oto); - from = e_iconv_charset_name(ofrom); + to = e_iconv_charset_name (oto); + from = e_iconv_charset_name (ofrom); tofrom = alloca(strlen(to) +strlen(from) + 2); sprintf(tofrom, "%s%%%s", to, from); -- cgit v1.2.3