[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#131881: debbugs: Even better MIME handling



Followup-For: Bug #131881
Package: debbugs
Version: N/A; reported 2002-02-19

I just checked the patches I sent in earlier on a live system. They work
very well. However, to be even better, the bodytoutf8 function should be:


sub bodytoutf8 {
    my $entity = shift;
    my $body = $entity->bodyhandle->as_string;
    my $charset = '';
    unless ($charset = $entity->head->mime_attr('content-type.charset')) {
	$charset = "US-ASCII";
    }
    $charset =~ tr/a-z/A-Z/;
    if (Unicode::MapUTF8::utf8_supported_charset($charset) and 
	    $entity->head->mime_type eq "text/plain") {
	$body = Unicode::MapUTF8::to_utf8({-string => $body, -charset => $charset});
    } else {
	$body = $entity->stringify_body;
    }
    return $body;
}


Also it's probably advisable to rename toutf8 to texttoutf8 for less
namespace pollution and clearer naming.

Note that this patch handles approximately 5 bugs. It is not really the
nice MIME handling that one would wish (and which seems to be
experimented with, when I interpret cgi-bin/mime correctly), but at
least it's an improvement over the current situation.

-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux kosh 2.4.13-586-ext3 #1 Die Nov 6 00:09:32 CET 2001 i686
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8

-- 
|=| Michael Piefel                    piefel@informatik.hu-berlin.de
|=| Humboldt-Universität zu Berlin              http://www.piefel.de
|=| Tel. (+49 30) 2093 3831



Reply to: