From 6dc2b5fac8deaa57b0a84f74dec98476a3066849 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Tue, 25 Sep 2001 20:49:26 +0000 Subject: If the data wrapper contains raw text, treat the contents as if they were 2001-09-25 Jeffrey Stedfast * mail-format.c (get_data_wrapper_text): If the data wrapper contains raw text, treat the contents as if they were in the user's default charset and convert them to UTF-8. svn path=/trunk/; revision=13119 --- mail/mail-format.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'mail/mail-format.c') diff --git a/mail/mail-format.c b/mail/mail-format.c index b1e3f9b5d1..584db2b01c 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -1040,15 +1040,31 @@ static char * get_data_wrapper_text (CamelDataWrapper *wrapper) { CamelStream *memstream; + CamelStreamFilter *filtered_stream; GByteArray *ba; char *text, *end; memstream = camel_stream_mem_new (); ba = g_byte_array_new (); camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (memstream), ba); - camel_data_wrapper_write_to_stream (wrapper, memstream); + + filtered_stream = camel_stream_filter_new_with_stream (memstream); camel_object_unref (CAMEL_OBJECT (memstream)); + if (wrapper->rawtext) { + CamelMimeFilterCharset *filter; + const char *charset; + + charset = mail_config_get_default_charset (); + filter = camel_mime_filter_charset_new_convert (charset, "utf-8"); + camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (filter)); + camel_object_unref (CAMEL_OBJECT (filter)); + } + + camel_data_wrapper_write_to_stream (wrapper, CAMEL_STREAM (filtered_stream)); + camel_stream_flush (CAMEL_STREAM (filtered_stream)); + camel_object_unref (CAMEL_OBJECT (filtered_stream)); + for (text = ba->data, end = text + ba->len; text < end; text++) { if (!isspace ((unsigned char)*text)) break; -- cgit v1.2.3