From 7a15ea11b11c309884e208849fcd6597a4c12b5a Mon Sep 17 00:00:00 2001 From: hiro Date: Wed, 9 Aug 2006 02:49:40 +0000 Subject: when inserting file, check whole file to see if it is UTF-8. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1121 ee746299-78ed-0310-b773-934348b2243d --- src/compose.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/compose.c') diff --git a/src/compose.c b/src/compose.c index ee237223..c16df187 100644 --- a/src/compose.c +++ b/src/compose.c @@ -1875,9 +1875,12 @@ static void compose_insert_file(Compose *compose, const gchar *file, gint len; FILE *fp; gboolean prev_autowrap; + CharSet enc; g_return_if_fail(file != NULL); + enc = conv_check_file_encoding(file); + if ((fp = g_fopen(file, "rb")) == NULL) { FILE_OP_ERROR(file, "fopen"); return; @@ -1896,15 +1899,19 @@ static void compose_insert_file(Compose *compose, const gchar *file, gchar *str; gint error = 0; - 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 (enc == C_UTF_8) { + str = g_strdup(buf); + } else { + 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; } - if (!str) continue; /* strip if DOS/Windows file, replace with if Macintosh file. */ -- cgit v1.2.3