diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-08-09 02:49:40 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-08-09 02:49:40 +0000 |
commit | 7a15ea11b11c309884e208849fcd6597a4c12b5a (patch) | |
tree | dedb62ea28c82654e05a4aa7901c1bebad1da9da /src/compose.c | |
parent | b536a7965390e03e8635c21d6c2d8d3d7efa8f04 (diff) |
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
Diffstat (limited to 'src/compose.c')
-rw-r--r-- | src/compose.c | 21 |
1 files changed, 14 insertions, 7 deletions
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 <CR> if DOS/Windows file, replace <CR> with <LF> if Macintosh file. */ |