[EMAIL PROTECTED] writes: >> Yes, in the general case, I agree that it's not unlikely. However, >> do you think for the specific case of templates it is likely? > > I've thought about this a bit more -- I guess it wouldn't be > unlikely if the Subject includes a bit of the original Subject.
This brings up a good point. Remember that when someone sends you a message, its Subject field is already encoded. This leads to problem if you want to combine that original subject with your own text that needs to be encoded. If the whole string is encoded, the already encoded part will be double-encoded turning it into gobbledygook. For example, from my template: Subject.EUC-JP: Please confirm / [EUC-JP text] (Re: %(subject)s) At first I didn't think this would be possible to support, but I've now got it working I think. Basically, I'm looking through the Subject value for an encoded part. If found, decode that, leaving the other portions alone. When creating the final Subject header, the non-encoded parts are encoded with the specified charset (EUC-JP), while the decoded portion is re-encoded with whatever charset it came with. Phew. See the attached screenshot. It simulates what would happen if someone sent me a message with a Swedish subject (ISO-8859-1) using the above example template line. Other combinations of charsets work the same. One remaining question is, are there any other headers besides Subject that should undergo this treatment? I can make it configurable, but I suspect Subject will normally be the only encoded header whose contents we care to use in our own headers.
<<attachment: subject.png>>
