aboutsummaryrefslogtreecommitdiff
path: root/src/compose.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-11-21 09:39:07 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-11-21 09:39:07 +0000
commit8c010a245f24fb83baf02ed397b2ea742eaae21c (patch)
tree9d0fcc200a11acde74b304ba5d28d3ff2cc7a3fd /src/compose.c
parenta7ff06e76f292fe17935eb1b2f09e145e054da76 (diff)
compose.c: give priority to locale to UTF-8 conversion.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@767 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/compose.c')
-rw-r--r--src/compose.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/compose.c b/src/compose.c
index 36898417..5983fc14 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -1775,14 +1775,19 @@ static gchar *compose_get_signature_str(Compose *compose)
sig_str = sig_body;
if (sig_str) {
- if (g_utf8_validate(sig_str, -1, NULL) == TRUE)
- utf8_sig_str = sig_str;
- else {
- utf8_sig_str = conv_codeset_strdup
- (sig_str, conv_get_locale_charset_str(),
- CS_INTERNAL);
+ gint error = 0;
+
+ utf8_sig_str = conv_codeset_strdup_full
+ (sig_str, conv_get_locale_charset_str(),
+ CS_INTERNAL, &error);
+ if (!utf8_sig_str || error != 0) {
+ if (g_utf8_validate(sig_str, -1, NULL) == TRUE) {
+ g_free(utf8_sig_str);
+ utf8_sig_str = sig_str;
+ } else
+ g_free(sig_str);
+ } else
g_free(sig_str);
- }
}
return utf8_sig_str;
@@ -1819,12 +1824,16 @@ static void compose_insert_file(Compose *compose, const gchar *file,
while (fgets(buf, sizeof(buf), fp) != NULL) {
gchar *str;
+ gint error = 0;
- if (g_utf8_validate(buf, -1, NULL) == TRUE)
- str = g_strdup(buf);
- else
- str = conv_codeset_strdup
- (buf, cur_encoding, CS_INTERNAL);
+ str = conv_codeset_strdup_full(buf, cur_encoding, CS_INTERNAL,
+ &error);
+ if (!str || error != 0) {
+ if (g_utf8_validate(buf, -1, NULL) == TRUE) {
+ g_free(str);
+ str = g_strdup(buf);
+ }
+ }
if (!str) continue;
/* strip <CR> if DOS/Windows file,