From 576273d8061657a192e1162ef4f428789b44f62c Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 29 Mar 2002 19:28:00 +0000 Subject: Use iconv-detect.c to generate a iconv-detect.h file containing 2002-03-29 Jeffrey Stedfast * configure.in: Use iconv-detect.c to generate a iconv-detect.h file containing information about the preferred charset formats to use with the system iconv. * iconv-detect.c: New program to detect the preferred charset formats for use with the system iconv. * gal/util/e-iconv.c (e_iconv_charset_name): Update to use macros defined in iconv-detect which is created at configure time. svn path=/trunk/; revision=16282 --- e-util/e-iconv.c | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'e-util/e-iconv.c') diff --git a/e-util/e-iconv.c b/e-util/e-iconv.c index 44c91fd412..7f18a5b43e 100644 --- a/e-util/e-iconv.c +++ b/e-util/e-iconv.c @@ -28,6 +28,7 @@ #include #include +#include #include #include "e-iconv.h" @@ -42,10 +43,7 @@ #include #endif -/* FIXME: Use feature test */ -#if !defined (__aix__) && !defined (__irix__) && !defined (__sun__) -#define ICONV_ISO_NEEDS_DASH (1) -#endif +#include "iconv-detect.h" #define cd(x) @@ -274,21 +272,43 @@ const char *e_iconv_charset_name(const char *charset) if (ret != NULL) { UNLOCK(); return ret; - - } /* Unknown, try canonicalise some basic charset types to something that should work */ if (strncmp(name, "iso", 3) == 0) { /* Convert iso-nnnn-n or isonnnn-n or iso_nnnn-n to iso-nnnn-n or isonnnn-n */ - tmp = name+3; - if (tmp[0] == '_' || tmp[0] == '-') + int iso, codepage; + char *p; + + tmp = name + 3; + if (*tmp == '-' || *tmp == '_') tmp++; -#ifdef ICONV_ISO_NEEDS_DASH - ret = g_strdup_printf("ISO-%s", tmp); -#else - ret = g_strdup_printf("ISO%s", tmp); -#endif + + iso = strtoul (tmp, &p, 10); + + if (iso == 10646) { + /* they all become ICONV_10646 */ + ret = g_strdup (ICONV_10646); + } else { + tmp = p; + if (*tmp == '-' || *tmp == '_') + tmp++; + + codepage = strtoul (tmp, &p, 10); + + if (p > tmp) { + /* codepage is numeric */ +#ifdef __aix__ + if (codepage == 13) + ret = g_strdup ("IBM-921"); + else +#endif /* __aix__ */ + ret = g_strdup_printf (ICONV_ISO_D_FORMAT, iso, codepage); + } else { + /* codepage is a string - probably iso-2022-jp or something */ + ret = g_strdup_printf (ICONV_ISO_S_FORMAT, iso, p); + } + } } else if (strncmp(name, "windows-", 8) == 0) { /* Convert windows-nnnnn or windows-cpnnnnn to cpnnnn */ tmp = name+8; -- cgit v1.2.3