diff options
Diffstat (limited to 'camel/camel-charset-map.c')
-rw-r--r-- | camel/camel-charset-map.c | 55 |
1 files changed, 55 insertions, 0 deletions
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 */ |