Sunday, March 01, 2009

Non-Ascii characters in MIME headers

Message Header Extensions for Non-ASCII Text: http://tools.ietf.org/html/rfc2047
The text is encoded in this ways:

   encoded-word = "=?" charset "?" encoding "?" encoded-text "?="
   charset = token    ; 
   encoding = token   ; 
   token = 1*<Any CHAR except SPACE, CTLs, and especials>
   especials = "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "
               <"> / "/" / "[" / "]" / "?" / "." / "="
   encoded-text = 1*<Any printable ASCII character other than "?" or SPACE>

Supported encodings  include "Q"(similar to quoted-printable) and "B" (Base64).

For example,

=?gb2312?Q?[CSDN]=C2=DB=CC=B3=D3=C3=BB=A7=BC=A4=BB=EE=CD=A8=D6=AA?=
represents text "[CSDN]论坛用户激活通知".
Note: SPACE and TAB are not allowed in encoded text. SPACE must be encoded using "=20".

No comments: