Index: unicode.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/unicode.inc,v
retrieving revision 1.23
diff -u -p -r1.23 unicode.inc
--- unicode.inc	6 Dec 2006 16:15:52 -0000	1.23
+++ unicode.inc	17 Feb 2007 23:35:43 -0000
@@ -236,13 +236,19 @@ function truncate_utf8($string, $len, $w
  * See http://www.rfc-editor.org/rfc/rfc2047.txt for more information.
  *
  * Notes:
- * - Only encode strings that contain non-ASCII characters.
+ * - Only encode strings that contain non-ASCII characters, unless the 
+ *   optional second parameter is defined.
  * - We progressively cut-off a chunk with truncate_utf8(). This is to ensure
  *   each chunk starts and ends on a character boundary.
  * - Using \n as the chunk separator may cause problems on some systems and may
  *   have to be changed to \r\n or \r.
+ *
+ * @param $string
+ *   The string to encode.
+ * @param $quoted
+ *   Perform quoted-string encoding of ASCII with special characters.
  */
-function mime_header_encode($string) {
+function mime_header_encode($string, $quoted = FALSE) {
   if (preg_match('/[^\x20-\x7E]/', $string)) {
     $chunk_size = 47; // floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
     $len = strlen($string);
@@ -256,6 +262,9 @@ function mime_header_encode($string) {
     }
     return trim($output);
   }
+  if ($quoted && preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $string)) {
+    return '"'. addcslashes($string, '\"') .'"';
+  }
   return $string;
 }
 
