Robert Brewer writes: > Syntactically, there's no sense in providing: > > Message.set_header('Subject', 'Some text', encoding='utf-16') > > ...since you could more clearly write the same as: > > Message.set_header('Subject', 'Some text'.encode('utf-16'))
Which you now must *parse* and guess the encoding to determine how to RFC-2047-encode the binary mush. I think the encoding parameter is necessary here. > But it would be far easier to do all the encoding at once in an > output() or serialize() method. Do different headers need different > encodings? You can have multiple encodings within a single header (and a naïve algorithm might very well encode "The price of Gödel-Escher-Bach is €25" as "The price of =?ISO-8859-1?Q?G=F6del-Escher-Bach?= is =?ISO-8859-15?Q?=A425?="). > If so, make message['Subject'] a subclass of str and give it an > .encoding attribute (with a default). But if you've set the .encoding attribute, you don't need to encode 'Some text'; .set_header() can take care of it for you. And what about the possibility that the encoding attributes disagree with the argument you passed to the codec? _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com