aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadek Doulik <rodo@ximian.com>2002-09-27 01:34:26 +0800
committerRadek Doulik <rodo@src.gnome.org>2002-09-27 01:34:26 +0800
commit2d412847ea2ae50c38fb1c3ece8bd1b7b754d565 (patch)
treef93f63aae2a477f3c80894c1a3369e4b6b41e2d3
parentd12a61b7104abba08476012dc7436a4bf2d43fe0 (diff)
downloadgsoc2013-evolution-2d412847ea2ae50c38fb1c3ece8bd1b7b754d565.tar.gz
gsoc2013-evolution-2d412847ea2ae50c38fb1c3ece8bd1b7b754d565.tar.zst
gsoc2013-evolution-2d412847ea2ae50c38fb1c3ece8bd1b7b754d565.zip
new helper function, g_strdown with forced C locale (e_iconv_init): use
2002-09-26 Radek Doulik <rodo@ximian.com> * gal/util/e-iconv.c (C_g_strdown): new helper function, g_strdown with forced C locale (e_iconv_init): use C_g_strdown (e_iconv_charset_name): ditto svn path=/trunk/; revision=18235
-rw-r--r--e-util/e-iconv.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/e-util/e-iconv.c b/e-util/e-iconv.c
index d241e1bf7d..0997878e81 100644
--- a/e-util/e-iconv.c
+++ b/e-util/e-iconv.c
@@ -187,6 +187,23 @@ static EDListNode *e_dlist_remove(EDListNode *n)
return n;
}
+/*
+ we don't want to lower charset names in native locale (look what does in such case ISO-8859-9),
+ but rather lower them in "pure" C locale
+ this fixes bug #24179
+*/
+static void
+C_g_strdown (gchar *string)
+{
+ gchar *old_locale;
+
+ old_locale = g_strdup (setlocale (LC_CTYPE, NULL));
+ setlocale (LC_CTYPE, "C");
+ g_strdown (string);
+ setlocale (LC_CTYPE, old_locale);
+ g_free (old_locale);
+}
+
/* NOTE: Owns the lock on return if keep is TRUE ! */
static void
e_iconv_init(int keep)
@@ -207,7 +224,7 @@ e_iconv_init(int keep)
for (i = 0; known_iconv_charsets[i].charset != NULL; i++) {
from = g_strdup(known_iconv_charsets[i].charset);
to = g_strdup(known_iconv_charsets[i].iconv_name);
- g_strdown(from);
+ C_g_strdown(from);
g_hash_table_insert(iconv_charsets, from, to);
}
@@ -227,7 +244,7 @@ e_iconv_init(int keep)
} else {
#ifdef HAVE_CODESET
locale_charset = g_strdup(nl_langinfo(CODESET));
- g_strdown(locale_charset);
+ C_g_strdown(locale_charset);
#else
/* A locale name is typically of the form language[_terri-
* tory][.codeset][@modifier], where language is an ISO 639
@@ -244,7 +261,7 @@ e_iconv_init(int keep)
/* ; is a hack for debian systems and / is a hack for Solaris systems */
for (p = codeset; *p && !strchr ("@;/", *p); p++);
locale_charset = g_strndup (codeset, p - codeset);
- g_strdown (locale_charset);
+ C_g_strdown (locale_charset);
} else {
/* charset unknown */
locale_charset = NULL;
@@ -265,7 +282,7 @@ const char *e_iconv_charset_name(const char *charset)
name = alloca(strlen(charset)+1);
strcpy(name, charset);
- g_strdown(name);
+ C_g_strdown(name);
e_iconv_init(TRUE);
ret = g_hash_table_lookup(iconv_charsets, name);