changeset 6119:9607369b6bce HEAD

Use message_header_decode_utf8() instead of implementing our own.
author Timo Sirainen <tss@iki.fi>
date Fri, 20 Jul 2007 12:11:51 +0300
parents 841b052e269e
children 00d1a94a94c6
files src/lib-imap/imap-base-subject.c
diffstat 1 files changed, 2 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap/imap-base-subject.c	Fri Jul 20 12:02:45 2007 +0300
+++ b/src/lib-imap/imap-base-subject.c	Fri Jul 20 12:11:51 2007 +0300
@@ -9,39 +9,6 @@
 #include "message-header-decode.h"
 #include "imap-base-subject.h"
 
-static bool header_decode(const unsigned char *data, size_t size,
-			  const char *charset, void *context)
-{
-	buffer_t *buf = context;
-        struct charset_translation *t;
-	unsigned char *buf_data;
-	size_t pos, used_size;
-
-	pos = buffer_get_used_size(buf);
-	if (charset == NULL) {
-		/* It's ASCII. */
-		buffer_append(buf, data, size);
-	} else {
-		t = charset_to_utf8_begin(charset, TRUE, NULL);
-		if (t != NULL) {
-			(void)charset_to_utf8(t, data, &size, buf);
-                        charset_to_utf8_end(&t);
-		}
-	}
-
-	if (size > 0) {
-		/* @UNSAFE: uppercase it. Current draft specifies that we
-		   should touch only ASCII. */
-		buf_data = buffer_get_modifiable_data(buf, &used_size);
-		for (; pos < used_size; pos++) {
-			if (buf_data[pos] >= 'a' && buf_data[pos] <= 'z')
-				buf_data[pos] = buf_data[pos] - 'a' + 'A';
-		}
-	}
-
-	return TRUE;
-}
-
 static void pack_whitespace(buffer_t *buf)
 {
 	char *data, *dest;
@@ -246,8 +213,8 @@
 	/* (1) Convert any RFC 2047 encoded-words in the subject to
 	   UTF-8.  Convert all tabs and continuations to space.
 	   Convert all multiple spaces to a single space. */
-	message_header_decode((const unsigned char *)subject, subject_len,
-			      header_decode, buf);
+	message_header_decode_utf8((const unsigned char *)subject, subject_len,
+				   buf, TRUE);
 	buffer_append_c(buf, '\0');
 
 	pack_whitespace(buf);