diff -urNp roundcubemail-0.1.1.org/program/include/rcube_imap.inc roundcubemail-0.1.1/program/include/rcube_imap.inc
--- roundcubemail-0.1.1.org/program/include/rcube_imap.inc	2008-10-01 15:13:36.000000000 +0900
+++ roundcubemail-0.1.1/program/include/rcube_imap.inc	2008-10-01 15:14:08.000000000 +0900
@@ -1247,7 +1247,7 @@ class rcube_imap
     if ($print)
       {
       $mode = $o_part->encoding == 'base64' ? 3 : ($o_part->encoding == 'quoted-printable' ? 1 : 2);
-      $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, $mode);
+      $body = iil_C_HandlePartBody($this->conn, $this->mailbox, $msg_id, $part, $mode, $o_part->mimetype);
       
       // we have to decode the part manually before printing
       if ($mode == 1)
diff -urNp roundcubemail-0.1.1.org/program/include/rcube_shared.inc roundcubemail-0.1.1/program/include/rcube_shared.inc
--- roundcubemail-0.1.1.org/program/include/rcube_shared.inc	2008-10-01 15:11:32.000000000 +0900
+++ roundcubemail-0.1.1/program/include/rcube_shared.inc	2008-10-01 15:14:08.000000000 +0900
@@ -712,6 +712,9 @@ function rc_mime_content_type($path, $fa
     }
     finfo_close($finfo);
 
+    # remains only contents-type
+    $mime_type = preg_replace ('/^([^;]*);.*/', '\\1', $mime_type);
+
     return $mime_type;
 }
 
diff -urNp roundcubemail-0.1.1.org/program/lib/Mail/mime.php roundcubemail-0.1.1/program/lib/Mail/mime.php
--- roundcubemail-0.1.1.org/program/lib/Mail/mime.php	2007-03-21 18:54:10.000000000 +0900
+++ roundcubemail-0.1.1/program/lib/Mail/mime.php	2008-10-01 15:14:08.000000000 +0900
@@ -327,7 +327,10 @@ class Mail_mime
                                            : $file;
         if ($isfile === true) {
             // Force the name the user supplied, otherwise use $file
-            $filename = (!empty($name)) ? $name : $file;
+			if (!empty($name))
+				$filename = $name;
+			else
+				$filename = (!empty($file)) ? basename($file) : '';
         } else {
             $filename = $name;
         }
@@ -337,7 +340,6 @@ class Mail_mime
             );
 	    return $err;
         }
-        $filename = basename($filename);
         if (PEAR::isError($filedata)) {
             return $filedata;
         }
diff -urNp roundcubemail-0.1.1.org/program/lib/Mail/mimePart.php roundcubemail-0.1.1/program/lib/Mail/mimePart.php
--- roundcubemail-0.1.1.org/program/lib/Mail/mimePart.php	2007-03-21 18:54:10.000000000 +0900
+++ roundcubemail-0.1.1/program/lib/Mail/mimePart.php	2008-10-01 15:14:08.000000000 +0900
@@ -138,7 +138,7 @@ class Mail_mimePart {
         foreach ($params as $key => $value) {
             switch ($key) {
                 case 'content_type':
-                    $headers['Content-Type'] = $value . (isset($charset) ? '; charset="' . $charset . '"' : '');
+                    $headers['Content-Type'] = $value . (!empty($charset) ? '; charset="' . $charset . '"' : '');
                     break;
 
                 case 'encoding':
@@ -168,9 +168,10 @@ class Mail_mimePart {
 
                 case 'charset':
                     if (isset($headers['Content-Type'])) {
-                        $headers['Content-Type'] .= '; charset="' . $value . '"';
+                        if (!empty($value) && empty($params['dfilename']))
+                            $headers['Content-Type'] .= '; charset="' . $value . '"';
                     } else {
-                        $charset = $value;
+                        $charset = empty($params['dfilename']) ? $value : '';
                     }
                     break;
             }
diff -urNp roundcubemail-0.1.1.org/program/lib/imap.inc roundcubemail-0.1.1/program/lib/imap.inc
--- roundcubemail-0.1.1.org/program/lib/imap.inc	2008-04-05 21:49:21.000000000 +0900
+++ roundcubemail-0.1.1/program/lib/imap.inc	2008-10-01 15:14:08.000000000 +0900
@@ -2301,7 +2301,7 @@ function iil_C_FetchPartHeader(&$conn, $
 }
 
 
-function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part, $mode) {
+function iil_C_HandlePartBody(&$conn, $mailbox, $id, $part, $mode, $mime = '') {
     /* modes:
         1: return string
         2: print
@@ -2330,6 +2330,10 @@ function iil_C_HandlePartBody(&$conn, $m
             $a    = explode(' ', $line);
         } while ($a[2] != 'FETCH');
         $len = strlen($line);
+
+        require 'lib/is_utf8.class.php';
+		$isutf = new IsUTF8;
+
         if ($line[$len-1] == ')') {
             //one line response, get everything between first and last quotes
             $from = strpos($line, '"') + 1;
@@ -2340,7 +2344,12 @@ function iil_C_HandlePartBody(&$conn, $m
             } else if ($mode == 2) {
                 echo substr($line, $from, $len);
             } else if ($mode == 3) {
-                echo base64_decode(substr($line, $from, $len));
+                $decode_str = base64_decode(substr($line, $from, $len));
+                if ($mime == 'text/plain' && !$isutf->is_utf8($decode_str)) {
+                    $decode_str = $isutf->remove_utf8bomb($decode_str);
+                    $decode_str = iconv ($GLOBALS['CONFIG']['default_charset'], 'UTF-8', $decode_str);
+                }
+                echo $decode_str;
             }
         }else if ($line[$len-1] == '}') {
             //multi-line request, find sizes of content and receive that many bytes
@@ -2364,8 +2373,16 @@ function iil_C_HandlePartBody(&$conn, $m
                 } else if ($mode == 2) {
                     echo chop($line) . "\n"; flush();
                 } else if ($mode == 3) {
-                    echo base64_decode($line); flush();
+                    $decode_str .= $line;
+                }
+            }
+            if ($mode == 3) {
+                $decode_str = base64_decode($decode_str);
+                if ($mime == 'text/plain' && !$isutf->is_utf8($decode_str)) {
+                    $decode_str = $isutf->remove_utf8bomb($decode_str);
+                    $decode_str = iconv ($GLOBALS['CONFIG']['default_charset'], 'UTF-8', $decode_str);
                 }
+			    echo $decode_str; flush();
             }
         }
         // read in anything up until 'til last line
diff -urNp roundcubemail-0.1.1.org/program/lib/is_utf8.class.php roundcubemail-0.1.1/program/lib/is_utf8.class.php
--- roundcubemail-0.1.1.org/program/lib/is_utf8.class.php	1970-01-01 09:00:00.000000000 +0900
+++ roundcubemail-0.1.1/program/lib/is_utf8.class.php	2008-10-01 15:14:08.000000000 +0900
@@ -0,0 +1,119 @@
+<?php
+/*
+ * Copyright (c) 2008, JoungKyun.Kim <http://oops.org>
+ * 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the authors nor the names of its contributors
+ *       may be used to endorse or promote products derived from this software
+ *       without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id: UTF8.php,v 1.1.1.1 2008/09/29 14:41:17 oops Exp $
+ * http://cvs.oops.org/?cvsroot=PHP-Module&module=pear_KSC5601
+ */
+
+class IsUTF8
+{
+	function chr2bin ($c, $shift = '') {
+		$c = ord ($c);
+
+		if ( $shift && preg_match ('/^([<>]+)[\s]*([0-9]+)/', $shift, $match) ) {
+			switch ($match[1]) {
+				case '>>' : $c = $c >> $match[2]; break;
+				case '<<' : $c = $c << $match[2]; break;
+				case '<'  : $c = $c <  $match[2]; break;
+				case '>'  : $c = $c >  $match[2]; break;
+			}
+		}
+
+		return decbin ($c);
+	}
+
+	function check2byte ($byte) {
+		return decbin (0x80 >> (8 - $byte));
+	}
+
+	function remove_utf8bomb ($str) {
+		if ( ord ($str[0]) == 0xef && ord ($str[1]) == 0xbb && ord($str[2]) == 0xbf )
+			return substr ($str, 3);
+
+		return $str;
+	}
+
+	function is_utf8 ($s) {
+		$s = $this->remove_utf8bomb ($s);
+		$l = strlen ($s);
+
+		for ( $i=0; $i<$l; $i++ ) {
+			# if single byte charactors, skipped
+			if ( ! (ord ($s[$i]) & 0x80) )
+				continue;
+
+			$first = $this->chr2bin ($s[$i]);
+
+			if ( substr ($first, 0, 2) == '10' )
+				return 0;
+
+			# excect 1st byte
+			$byte = strlen (preg_replace ('/^([1]+).*/', '\\1', $first));
+
+			if ( $byte > 6 )
+				continue;
+
+			/*
+			 * 2byte: 1100000x (10xxxxxx)
+			 * 3byte: 11100000 100xxxxx (10xxxxxx)
+			 * 4byte: 11110000 1000xxxx (10xxxxxx 10xxxxxx)
+			 * 5byte: 11111000 10000xxx (10xxxxxx 10xxxxxx 10xxxxxx)
+			 * 6byte: 11111100 100000xx (10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
+			 */
+			for ( $j=1; $j<$byte; $j++ ) {
+				if ( $j == 1 ) {
+					$n = 8 - $byte;
+					if ( $this->chr2bin ($s[$i+1], ">>$n") != $this->check2byte($byte) )
+						return 0;
+
+					continue;
+				}
+
+				if ( $this->chr2bin ($s[$i+$j], '>>6') != 10 )
+					return 0;
+			}
+
+			break;
+		}
+
+		return 1;
+	}
+}
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4 
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
+?>
