2005-09-18 [colin] 1.9.14cvs39
[claws.git] / src / codeconv.c
index d2d636a58d8fc156bc385dffca7791407ccf7021..3e7676b11b0f82f822078b61b471729c888348ec 100644 (file)
@@ -672,9 +672,12 @@ void conv_localetodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
 
        tmpstr = conv_iconv_strdup(inbuf, conv_get_locale_charset_str(),
                                   CS_INTERNAL);
-       if (tmpstr) {
+       if (tmpstr && g_utf8_validate(tmpstr, -1, NULL)) {
                strncpy2(outbuf, tmpstr, outlen);
                g_free(tmpstr);
+       } else if (tmpstr && !g_utf8_validate(tmpstr, -1, NULL)) {
+               g_free(tmpstr);
+               conv_utf8todisp(outbuf, outlen, inbuf);
        } else
                conv_utf8todisp(outbuf, outlen, inbuf);
 }
@@ -1022,7 +1025,11 @@ static const struct {
        {"ja_JP.ujis"   , C_EUC_JP      , C_ISO_2022_JP},
        {"ja_JP.SJIS"   , C_SHIFT_JIS   , C_ISO_2022_JP},
        {"ja_JP.JIS"    , C_ISO_2022_JP , C_ISO_2022_JP},
+#ifdef G_OS_WIN32
+       {"ja_JP"        , C_SHIFT_JIS   , C_ISO_2022_JP},
+#else
        {"ja_JP"        , C_EUC_JP      , C_ISO_2022_JP},
+#endif
        {"ko_KR.EUC-KR" , C_EUC_KR      , C_EUC_KR},
        {"ko_KR"        , C_EUC_KR      , C_EUC_KR},
        {"zh_CN.GB2312" , C_GB2312      , C_GB2312},
@@ -1404,10 +1411,14 @@ const gchar *conv_get_current_locale(void)
 {
        const gchar *cur_locale;
 
+#ifdef G_OS_WIN32
+       cur_locale = g_win32_getlocale();
+#else
        cur_locale = g_getenv("LC_ALL");
        if (!cur_locale) cur_locale = g_getenv("LC_CTYPE");
        if (!cur_locale) cur_locale = g_getenv("LANG");
        if (!cur_locale) cur_locale = setlocale(LC_CTYPE, NULL);
+#endif /* G_OS_WIN32 */
 
        debug_print("current locale: %s\n",
                    cur_locale ? cur_locale : "(none)");