diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-03-30 03:28:00 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-03-30 03:28:00 +0800 |
commit | 576273d8061657a192e1162ef4f428789b44f62c (patch) | |
tree | 9e95fb85df78d99ff3c92da2d85cdab951dc7aed /e-util | |
parent | 02c6da774e30c0a3c3936851e149edd7bb7ee401 (diff) | |
download | gsoc2013-evolution-576273d8061657a192e1162ef4f428789b44f62c.tar gsoc2013-evolution-576273d8061657a192e1162ef4f428789b44f62c.tar.gz gsoc2013-evolution-576273d8061657a192e1162ef4f428789b44f62c.tar.bz2 gsoc2013-evolution-576273d8061657a192e1162ef4f428789b44f62c.tar.lz gsoc2013-evolution-576273d8061657a192e1162ef4f428789b44f62c.tar.xz gsoc2013-evolution-576273d8061657a192e1162ef4f428789b44f62c.tar.zst gsoc2013-evolution-576273d8061657a192e1162ef4f428789b44f62c.zip |
Use iconv-detect.c to generate a iconv-detect.h file containing
2002-03-29 Jeffrey Stedfast <fejj@ximian.com>
* 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
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-iconv.c | 46 |
1 files changed, 33 insertions, 13 deletions
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 <string.h> #include <stdio.h> +#include <stdlib.h> #include <glib.h> #include "e-iconv.h" @@ -42,10 +43,7 @@ #include <langinfo.h> #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; |