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?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4