the best bet today for fetched messages seems to be decoding per user preferences and defaultsand that' how we'll proceed in this edition the pymailgui client of for instancewill allow unicode encodings for full mail text to be set on persession basis the real issueof courseis that email in general is inherently complicated by the presence of arbitrary text encodings besides full mail textwe also must consider unicode encoding issues for the text components of message once it' parsed--both its text parts and its message headers to see whylet' move on related issue for cgi scriptsi should also note that the full text decoding issue may not be as large factor for email as it is for some other email package clients because the original email standards call for ascii text and require binary data to be mime encodedmost emails are likely to decode properly according to or -bit encoding such as latin- as we'll see in thougha more insurmountable and related issue looms for server-side scripts that support cgi file uploads on the web--because python' cgi module also uses the email package to parse multipart form databecause this package requires data to be decoded to str for parsingand because such data might have mixed text and binary data (included raw binary data that is not mime-encodedtext of any encodingand even arbitrary combinations of these)these uploads fail in python if any binary or incompatible text files are included the cgi module triggers unicode decoding or type errors internallybefore the python script has chance to intervene cgi uploads worked in python xbecause the str type represented both possibly encoded text and binary data saving this type' content to binary mode file as string of bytes in sufficed for both arbitrary text and binary data such as images email parsing worked in for the same reason for better or worsethe str/bytes dichotomy makes this generality impossible in other wordsalthough we can generally work around the email parser' str requirement for fetched emails by decoding per an -bit encodingit' much more malignant for web scripting today watch for more details on this in and stay tuned for future fixwhich may have materialized by the time you read these words text payload encodingshandling mixed type results our next email unicode issue seems to fly in the face of python' generic programming modelthe data types of message payload objects may differdepending on how they are fetched especially for programs that walk and process payloads of mail parts genericallythis complicates code emailparsing and composing mail content