[imp] charset used to encode headers

Wenzhuo Zhang wenzhuo@zhmail.com
Thu, 4 Jul 2002 20:43:08 +0800


Hi,

Today I noticed a charset problem of MIME-encoded message headers when
writing messages with subjects in Chinese.

I was using IMP-3.1 with the language set to "Chinese (Simplified".  I
found that IMP picks up a charset in 'HTTP_ACCEPT_CHARSET', which is
iso-8859-1 in my case (mozilla-1.0.0), to encode the subject header,
disregarding the default charset GB2312 of the session. Thus, the body
and the subject of sent messages are in different charsets.

  User-Agent: Internet Messaging Program (IMP) 3.1
  Subject: =?ISO-8859-1?B?UmU6ILLiytQ=?=
  Content-Type: text/plain; charset=GB2312

This is obviously causing interoperability problems with Mutt. To
display Chinese messages, the default charset of Mutt has to be set to
GB2312. But if the subject is in iso8859-1, Mutt tries to convert it
from iso-8859-1 to gb2312. It fails, 'cause the non-ASCII characters in
iso-8859-1 do not have equivalents in gb2312.  Therefore "????"
characters are displayed instead. - A friend told me Outlook Express
cannot properly display the subject lines of such messages either.

To fix the problem, I commented out the following chunk of code in
MIME_Message::encode():

--- horde/lib/MIME/Message.php.dist     Sun Apr  7 00:19:20 2002
+++ horde/lib/MIME/Message.php  Thu Jul  4 19:45:54 2002
@@ -63,6 +63,7 @@
      */
     function encode($headers)
     {
+/*
         global $HTTP_SERVER_VARS;
 
         if (!empty($HTTP_SERVER_VARS['HTTP_ACCEPT_CHARSET'])) {
@@ -74,6 +75,7 @@
                 }
             }
         }
+*/
         if (empty($charset)) {
             $charset = Lang::getCharset();
         }


Does it make sense?

-- 
Wenzhuo
  GnuPG Key ID 0xBA586A68
  Key fingerprint = 89C7 C6DE D956 F978 3F12  A8AF 5847 F840 BA58 6A68