From 8c010a245f24fb83baf02ed397b2ea742eaae21c Mon Sep 17 00:00:00 2001 From: hiro Date: Mon, 21 Nov 2005 09:39:07 +0000 Subject: 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 --- ChangeLog | 7 +++++++ ChangeLog.ja | 7 +++++++ src/compose.c | 33 +++++++++++++++++++++------------ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4fe11f3..758a628e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-11-21 + + * src/compose.c: + compose_get_signature_str() + compose_insert_file(): give priority to locale to UTF-8 conversion + (fixes wrong Japanese conversion on some case). + 2005-11-21 * libsylph/prefs_common.[ch]: modified the order of options. diff --git a/ChangeLog.ja b/ChangeLog.ja index 54d38b2d..bfdc7ff5 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,3 +1,10 @@ +2005-11-21 + + * src/compose.c: + compose_get_signature_str() + compose_insert_file(): ロケール→UTF-8 変換を優先するようにした + (日本語の変換を一部誤るのを修正)。 + 2005-11-21 * libsylph/prefs_common.[ch]: オプションの順序を変更。 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 if DOS/Windows file, -- cgit v1.2.3