diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-08-31 09:46:44 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-08-31 09:46:44 +0800 |
commit | dbe98bddd36330aaca54af847593d05742da3840 (patch) | |
tree | a87450fba3d82f8717def85319bdc6e0e68727ba /camel/camel-mime-utils.c | |
parent | d4a67b5d3b738cbc61056f06ead766ce5cee2985 (diff) | |
download | gsoc2013-evolution-dbe98bddd36330aaca54af847593d05742da3840.tar.gz gsoc2013-evolution-dbe98bddd36330aaca54af847593d05742da3840.tar.zst gsoc2013-evolution-dbe98bddd36330aaca54af847593d05742da3840.zip |
New function - even though its broken, we'll assume mailers send latin1
2000-08-31 Not Zed <NotZed@HelixCode.com>
* camel-mime-utils.c (append_latin1): New function - even though
its broken, we'll assume mailers send latin1 headers instead of
us-ascii. We just have to encode high chars into utf-8.
(header_decode_text): Call append_latin1 for appending unencoded
text segments.
svn path=/trunk/; revision=5128
Diffstat (limited to 'camel/camel-mime-utils.c')
-rw-r--r-- | camel/camel-mime-utils.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index 90d7496ce3..193d9d00c5 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -914,6 +914,28 @@ g_string_append_len(GString *st, const char *s, int l) return g_string_append(st, tmp); } +/* ok, a lot of mailers are BROKEN, and send iso-latin1 encoded + headers, when they should just be sticking to US-ASCII + according to the rfc's. Anyway, since the conversion to utf-8 + is trivial, just do it here without iconv */ +static GString * +append_latin1(GString *out, const char *in, int len) +{ + unsigned int c; + + while (len) { + c = (unsigned int)*in++; + len--; + if (c & 0x80) { + out = g_string_append_c(out, 0xc0 | (c>>6)); /* 110000xx */ + out = g_string_append_c(out, 0x80 | (c&0x3f)); /* 10xxxxxx */ + } else { + out = g_string_append_c(out, c); + } + } + return out; +} + /* decodes a simple text, rfc822 */ static char * header_decode_text(const char *in, int inlen) @@ -934,11 +956,11 @@ header_decode_text(const char *in, int inlen) out = g_string_append_len(out, decword, strlen(decword)); g_free (decword); } else { - out = g_string_append_len(out, inptr, encend-inptr+2); + out = append_latin1(out, inptr, encend-inptr+2); } inptr = encend+2; } - out = g_string_append_len(out, inptr, inend-inptr); + out = append_latin1(out, inptr, inend-inptr); encstart = out->str; g_string_free(out, FALSE); |