--- /opt/wordpress/wp-mail.php	2007-12-29 19:38:34.000000000 +0000
+++ wp-mail.php	2008-04-23 07:21:37.000000000 +0000
@@ -29,6 +29,7 @@
 
 	$content = '';
 	$content_type = '';
+	$content_type_charset = '';
 	$content_transfer_encoding = '';
 	$boundary = '';
 	$bodysignal = 0;
@@ -42,10 +43,21 @@
 			$content .= $line;
 		} else {
 			if (preg_match('/Content-Type: /i', $line)) {
+				echo "content-type-line: $line<br>";
 				$content_type = trim($line);
 				$content_type = substr($content_type, 14, strlen($content_type)-14);
 				$content_type = explode(';', $content_type);
+				for ( $ctp = 1 ; $ctp < count($content_type) ; $ctp++ ) {
+					$candidate = $content_type[$ctp];
+					echo "candidate: $candidate<br>";
+					if ( preg_match('/charset=/i', $candidate) ) {
+						$content_type_charset=explode('=', $candidate);
+						$content_type_charset=$content_type_charset[1];
+						$content_type_charset=trim($content_type_charset);
+					}
+				}
 				$content_type = $content_type[0];
+				echo "content-type: $content_type<br>content-type-charset: '$content_type_charset'<br>";
 			}
 			if (preg_match('/Content-Transfer-Encoding: /i', $line)) {
 				$content_transfer_encoding = trim($line);
@@ -61,8 +73,9 @@
 			if (preg_match('/Subject: /i', $line)) {
 				$subject = trim($line);
 				$subject = substr($subject, 9, strlen($subject)-9);
-				$subject = wp_iso_descrambler($subject);
-				// Captures any text in the subject before $phone_delim as the subject
+				// $subject = wp_iso_descrambler($subject);
+				$subject = iconv_mime_decode($subject,2,'utf8');
+                                // Captures any text in the subject before $phone_delim as the subject
 				$subject = explode($phone_delim, $subject);
 				$subject = $subject[0];
 			}
@@ -148,6 +161,13 @@
 		$content = quoted_printable_decode($content);
 	}
 
+	if (strlen($content_type_charset)) {
+		echo "converting '$content_type_charset' to 'utf8'<br>";
+		echo "content before: $content<br>";
+		$content = iconv($content_type_charset,'utf8',$content);
+		echo "content after: $content<br>";	
+	}
+
 	// Captures any text in the body after $phone_delim as the body
 	$content = explode($phone_delim, $content);
 	$content[1] ? $content = $content[1] : $content = $content[0];
