2005-06-15 [paul] 1.9.11cvs71
[claws.git] / src / codeconv.c
index 877d48d882facba7ab56d1018cab324c89ea251f..cc2eeb3530681dfb7582698e1f48e95211d0e490 100644 (file)
@@ -771,7 +771,7 @@ CodeConvFunc conv_get_code_conv_func(const gchar *src_charset_str,
 
        /* auto detection mode */
        if (!src_charset_str && !dest_charset_str) {
-               if (src_charset == C_EUC_JP || src_charset == C_SHIFT_JIS)
+               if (conv_is_ja_locale())
                        return conv_anytodisp;
                else
                        return conv_noconv;
@@ -1364,14 +1364,6 @@ const gchar *conv_get_outgoing_charset_str(void)
        CharSet out_charset;
        const gchar *str;
 
-       if (prefs_common.outgoing_charset) {
-               if (!isalpha((guchar)prefs_common.outgoing_charset[0])) {
-                       g_free(prefs_common.outgoing_charset);
-                       prefs_common.outgoing_charset = g_strdup(CS_AUTO);
-               } else if (strcmp(prefs_common.outgoing_charset, CS_AUTO) != 0)
-                       return prefs_common.outgoing_charset;
-       }
-
        out_charset = conv_get_outgoing_charset();
        str = conv_get_charset_str(out_charset);
 
@@ -1418,6 +1410,24 @@ const gchar *conv_get_current_locale(void)
        return cur_locale;
 }
 
+gboolean conv_is_ja_locale(void)
+{
+       static gint is_ja_locale = -1;
+       const gchar *cur_locale;
+
+       if (is_ja_locale != -1)
+               return is_ja_locale != 0;
+
+       is_ja_locale = 0;
+       cur_locale = conv_get_current_locale();
+       if (cur_locale) {
+               if (g_ascii_strncasecmp(cur_locale, "ja", 2) == 0)
+                       is_ja_locale = 1;
+       }
+
+       return is_ja_locale != 0;
+}
+
 gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding)
 {
        gchar buf[BUFFSIZE];
@@ -1439,7 +1449,7 @@ gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding)
                }
        }
 
-       if (conv_get_locale_charset() == C_EUC_JP)
+       if (conv_is_ja_locale())
                conv_anytodisp(buf, sizeof(buf), str);
        else
                conv_localetodisp(buf, sizeof(buf), str);