+2005-09-18 [colin] 1.9.14cvs42
+
+ * src/codeconv.c
+ * src/codeconv.h
+ * src/procmime.c
+ Add a way to get locale's charset ignoring utf-8,
+ and use that as default encoding for broken mails
+
2005-09-18 [colin] 1.9.14cvs41
* src/gtk/logwindow.c
( cvs diff -u -r 1.65.2.35 -r 1.65.2.36 src/codeconv.c; cvs diff -u -r 1.382.2.170 -r 1.382.2.171 src/compose.c; cvs diff -u -r 1.49.2.60 -r 1.49.2.61 src/procmime.c; ) > 1.9.14cvs39.patchset
( cvs diff -u -r 1.654.2.850 -r 1.654.2.851 configure.ac; ) > 1.9.14cvs40.patchset
( cvs diff -u -r 1.1.4.10 -r 1.1.4.11 src/gtk/logwindow.c; ) > 1.9.14cvs41.patchset
+( cvs diff -u -r 1.65.2.36 -r 1.65.2.37 src/codeconv.c; cvs diff -u -r 1.15.2.10 -r 1.15.2.11 src/codeconv.h; cvs diff -u -r 1.49.2.61 -r 1.49.2.62 src/procmime.c; ) > 1.9.14cvs42.patchset
MICRO_VERSION=14
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=41
+EXTRA_VERSION=42
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
return cur_charset;
}
+static CharSet conv_get_locale_charset_no_utf8(void)
+{
+ static CharSet cur_charset = -1;
+ const gchar *cur_locale;
+ const gchar *p;
+ gchar *tmp;
+ gint i;
+
+ if (cur_charset != -1)
+ return cur_charset;
+
+ cur_locale = conv_get_current_locale();
+ if (!cur_locale) {
+ cur_charset = C_US_ASCII;
+ return cur_charset;
+ }
+
+ if (strcasestr(cur_locale, "UTF-8")) {
+ tmp = g_strdup(cur_locale);
+ *(strcasestr(tmp, ".UTF-8")) = '\0';
+ cur_locale = tmp;
+ }
+
+ if ((p = strcasestr(cur_locale, "@euro")) && p[5] == '\0') {
+ cur_charset = C_ISO_8859_15;
+ return cur_charset;
+ }
+
+ for (i = 0; i < sizeof(locale_table) / sizeof(locale_table[0]); i++) {
+ const gchar *p;
+
+ /* "ja_JP.EUC" matches with "ja_JP.eucJP", "ja_JP.EUC" and
+ "ja_JP". "ja_JP" matches with "ja_JP.xxxx" and "ja" */
+ if (!g_ascii_strncasecmp(cur_locale, locale_table[i].locale,
+ strlen(locale_table[i].locale))) {
+ cur_charset = locale_table[i].charset;
+ return cur_charset;
+ } else if ((p = strchr(locale_table[i].locale, '_')) &&
+ !strchr(p + 1, '.')) {
+ if (strlen(cur_locale) == 2 &&
+ !g_ascii_strncasecmp(cur_locale, locale_table[i].locale, 2)) {
+ cur_charset = locale_table[i].charset;
+ return cur_charset;
+ }
+ }
+ }
+
+ cur_charset = C_AUTO;
+ return cur_charset;
+}
+
const gchar *conv_get_locale_charset_str(void)
{
static const gchar *codeset = NULL;
return codeset ? codeset : CS_INTERNAL;
}
+const gchar *conv_get_locale_charset_str_no_utf8(void)
+{
+ static const gchar *codeset = NULL;
+
+ if (!codeset)
+ codeset = conv_get_charset_str(conv_get_locale_charset_no_utf8());
+
+ return codeset ? codeset : CS_INTERNAL;
+}
+
CharSet conv_get_internal_charset(void)
{
return C_INTERNAL;
CharSet conv_get_charset_from_str (const gchar *charset);
CharSet conv_get_locale_charset (void);
const gchar *conv_get_locale_charset_str (void);
+const gchar *conv_get_locale_charset_str_no_utf8(void);
CharSet conv_get_internal_charset (void);
const gchar *conv_get_internal_charset_str (void);
CharSet conv_get_outgoing_charset (void);
mimeinfo->subtype = g_strdup("plain");
if (g_hash_table_lookup(mimeinfo->typeparameters,
"charset") == NULL) {
- if (strcmp(conv_get_locale_charset_str(), CS_UTF_8))
- g_hash_table_insert(mimeinfo->typeparameters,
- g_strdup("charset"),
- g_strdup(conv_get_locale_charset_str()));
- else
- g_hash_table_insert(mimeinfo->typeparameters,
- g_strdup("charset"),
- g_strdup(CS_ISO_8859_1));
+ g_hash_table_insert(mimeinfo->typeparameters,
+ g_strdup("charset"),
+ g_strdup(
+ conv_get_locale_charset_str_no_utf8()));
}
} else {
gchar *type, *subtype, *params;
mimeinfo->subtype = g_strdup("plain");
if (g_hash_table_lookup(mimeinfo->typeparameters,
"charset") == NULL) {
- if (strcmp(conv_get_locale_charset_str(), CS_UTF_8))
- g_hash_table_insert(mimeinfo->typeparameters,
- g_strdup("charset"),
- g_strdup(conv_get_locale_charset_str()));
- else
- g_hash_table_insert(mimeinfo->typeparameters,
- g_strdup("charset"),
- g_strdup(CS_ISO_8859_1));
+ g_hash_table_insert(mimeinfo->typeparameters,
+ g_strdup("charset"),
+ g_strdup(
+ conv_get_locale_charset_str_no_utf8()));
}
}