From f6408daa103092f18789a719a4123224b259f71f Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 18 Dec 2001 01:28:27 +0000 Subject: New function to map ISO charsets to the Windows charsets. 2001-12-17 Jeffrey Stedfast * camel-charset-map.c (camel_charset_iso_to_windows): New function to map ISO charsets to the Windows charsets. * camel-mime-part-utils.c (broken_windows_charset): Detect Windows charsets. (simple_data_wrapper_construct_from_parser): Simplify a tad and also check for iso-8859-* charsets that are really Windows charsets. Fixes bug #12631. svn path=/trunk/; revision=15144 --- camel/camel-charset-map.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'camel/camel-charset-map.c') diff --git a/camel/camel-charset-map.c b/camel/camel-charset-map.c index 17962d74be..2416dd2504 100644 --- a/camel/camel-charset-map.c +++ b/camel/camel-charset-map.c @@ -292,5 +292,60 @@ camel_charset_best (const char *in, int len) return camel_charset_best_name (&charset); } + +/** + * camel_charset_iso_to_windows: + * @isocharset: an ISO charset + * + * Returns the equivalent Windows charset. + **/ +const char * +camel_charset_iso_to_windows (const char *isocharset) +{ + /* According to http://czyborra.com/charsets/codepages.html, + * the charset mapping is as follows: + * + * iso-8859-1 maps to windows-cp1252 + * iso-8859-2 maps to windows-cp1250 + * iso-8859-3 maps to windows-cp???? + * iso-8859-4 maps to windows-cp???? + * iso-8859-5 maps to windows-cp1251 + * iso-8859-6 maps to windows-cp1256 + * iso-8859-7 maps to windows-cp1253 + * iso-8859-8 maps to windows-cp1255 + * iso-8859-9 maps to windows-cp1254 + * iso-8859-10 maps to windows-cp???? + * iso-8859-11 maps to windows-cp???? + * iso-8859-12 maps to windows-cp???? + * iso-8859-13 maps to windows-cp1257 + * + * Assumptions: + * - I'm going to assume that since iso-8859-4 and + * iso-8859-13 are Baltic that it also maps to + * windows-cp1257. + */ + + if (!strcasecmp (isocharset, "iso-8859-1")) + return "windows-cp1252"; + else if (!strcasecmp (isocharset, "iso-8859-2")) + return "windows-cp1250"; + else if (!strcasecmp (isocharset, "iso-8859-4")) + return "windows-cp1257"; + else if (!strcasecmp (isocharset, "iso-8859-5")) + return "windows-cp1251"; + else if (!strcasecmp (isocharset, "iso-8859-6")) + return "windows-cp1256"; + else if (!strcasecmp (isocharset, "iso-8859-7")) + return "windows-cp1253"; + else if (!strcasecmp (isocharset, "iso-8859-8")) + return "windows-cp1255"; + else if (!strcasecmp (isocharset, "iso-8859-9")) + return "windows-cp1254"; + else if (!strcasecmp (isocharset, "iso-8859-13")) + return "windows-cp1257"; + + return isocharset; +} + #endif /* !BUILD_MAP */ -- cgit v1.2.3