aboutsummaryrefslogtreecommitdiff
path: root/src/codeconv.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-02-22 10:05:49 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-02-22 10:05:49 +0000
commitd759c99df0ad6f2b774691c82daf9fc18f57498d (patch)
tree55cc1abff1f58cc89c4d9ee33e5291ce9785dfe6 /src/codeconv.c
parentf38dc1d07970872159cba1209e58408078e690a5 (diff)
try to convert unencoded header strings using locale encoding.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@121 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/codeconv.c')
-rw-r--r--src/codeconv.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/codeconv.c b/src/codeconv.c
index c8329681..d78c2439 100644
--- a/src/codeconv.c
+++ b/src/codeconv.c
@@ -797,6 +797,8 @@ void conv_utf8todisp(gchar *outbuf, gint outlen, const gchar *inbuf)
static void conv_anytodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
{
conv_anytoutf8(outbuf, outlen, inbuf);
+ if (g_utf8_validate(outbuf, -1, NULL) != TRUE)
+ conv_unreadable_8bit(outbuf);
}
static void conv_ustodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
@@ -815,7 +817,7 @@ void conv_localetodisp(gchar *outbuf, gint outlen, const gchar *inbuf)
strncpy2(outbuf, tmpstr, outlen);
g_free(tmpstr);
} else
- strncpy2(outbuf, inbuf, outlen);
+ conv_utf8todisp(outbuf, outlen, inbuf);
}
static void conv_noconv(gchar *outbuf, gint outlen, const gchar *inbuf)
@@ -1545,40 +1547,33 @@ void conv_unmime_header_overwrite(gchar *str)
{
gchar *buf;
gint buflen;
- CharSet cur_charset;
- cur_charset = conv_get_locale_charset();
+ buflen = strlen(str) * 2 + 1;
+ Xalloca(buf, buflen, return);
- if (cur_charset == C_EUC_JP) {
- buflen = strlen(str) * 2 + 1;
- Xalloca(buf, buflen, return);
+ if (conv_get_locale_charset() == C_EUC_JP)
conv_anytodisp(buf, buflen, str);
- unmime_header(str, buf);
- } else {
- buflen = strlen(str) + 1;
- Xalloca(buf, buflen, return);
- unmime_header(buf, str);
- strncpy2(str, buf, buflen);
- }
+ else
+ conv_localetodisp(buf, buflen, str);
+
+ unmime_header(str, buf);
}
void conv_unmime_header(gchar *outbuf, gint outlen, const gchar *str,
const gchar *charset)
{
- CharSet cur_charset;
-
- cur_charset = conv_get_locale_charset();
+ gchar *buf;
+ gint buflen;
- if (cur_charset == C_EUC_JP) {
- gchar *buf;
- gint buflen;
+ buflen = strlen(str) * 2 + 1;
+ Xalloca(buf, buflen, return);
- buflen = strlen(str) * 2 + 1;
- Xalloca(buf, buflen, return);
+ if (conv_get_locale_charset() == C_EUC_JP)
conv_anytodisp(buf, buflen, str);
- unmime_header(outbuf, buf);
- } else
- unmime_header(outbuf, str);
+ else
+ conv_localetodisp(buf, buflen, str);
+
+ unmime_header(outbuf, buf);
}
#define MAX_LINELEN 76