aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-charset-map.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-04-11 23:45:35 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-04-11 23:45:35 +0800
commit1a0534367e544cc35e3c171fbddc552bb2945a9c (patch)
treef1bbf5e2bea5fadfc9561942b0f00aee3bd3e8b8 /camel/camel-charset-map.c
parent1ca457947eac5004f6af55d0d9a45cdc17790207 (diff)
downloadgsoc2013-evolution-1a0534367e544cc35e3c171fbddc552bb2945a9c.tar
gsoc2013-evolution-1a0534367e544cc35e3c171fbddc552bb2945a9c.tar.gz
gsoc2013-evolution-1a0534367e544cc35e3c171fbddc552bb2945a9c.tar.bz2
gsoc2013-evolution-1a0534367e544cc35e3c171fbddc552bb2945a9c.tar.lz
gsoc2013-evolution-1a0534367e544cc35e3c171fbddc552bb2945a9c.tar.xz
gsoc2013-evolution-1a0534367e544cc35e3c171fbddc552bb2945a9c.tar.zst
gsoc2013-evolution-1a0534367e544cc35e3c171fbddc552bb2945a9c.zip
Use camel_charset_locale_name() to get the locale charset rather than
2001-04-11 Jeffrey Stedfast <fejj@ximian.com> * camel-sasl-digest-md5.c (digest_response): Use camel_charset_locale_name() to get the locale charset rather than checking the CHARSET environment variable. This is a much less ugly hack. Also: If we fail to be able to convert to UTF8, then disavow all knowledge of the charset parameter. * camel-charset-map.c (camel_charset_locale_name): New function to return the locale charset (or NULL if US-ASCII). svn path=/trunk/; revision=9237
Diffstat (limited to 'camel/camel-charset-map.c')
-rw-r--r--camel/camel-charset-map.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/camel/camel-charset-map.c b/camel/camel-charset-map.c
index c8974af936..d5d7665dac 100644
--- a/camel/camel-charset-map.c
+++ b/camel/camel-charset-map.c
@@ -202,6 +202,7 @@ void main(void)
#include "camel-charset-map.h"
#include "camel-charset-map-private.h"
#include <unicode.h>
+#include <locale.h>
#include <glib.h>
void camel_charset_init(CamelCharset *c)
@@ -282,6 +283,40 @@ camel_charset_best(const char *in, int len)
return camel_charset_best_name(&charset);
}
+char *
+camel_charset_locale_name (void)
+{
+ char *locale, *charset;
+
+ locale = setlocale (LC_ALL, NULL);
+
+ if (!locale || !strcmp (locale, "C") || !strcmp (locale, "POSIX")) {
+ /* The locale "C" or "POSIX" is a portable locale; its
+ * LC_CTYPE part corresponds to the 7-bit ASCII character
+ * set.
+ */
+
+ return NULL;
+ } else {
+ /* A locale name is typically of the form language[_terri-
+ * tory][.codeset][@modifier], where language is an ISO 639
+ * language code, territory is an ISO 3166 country code, and
+ * codeset is a character set or encoding identifier like
+ * ISO-8859-1 or UTF-8.
+ */
+ char *p;
+ int len;
+
+ p = strchr (locale, '@');
+ len = p ? (p - locale) : strlen (locale);
+ if ((p = strchr (locale, '.'))) {
+ charset = g_strndup (p + 1, len - (p - locale) + 1);
+ g_strdown (charset);
+ }
+ }
+
+ return charset;
+}
#endif /* !BUILD_MAP */