Hi Tim,

It looks like Mime Encoded Printable text. The library at the following 
URL may sort you aout:

http://docs.python.org/library/quopri.html

Regards,


John C.


Tim Kersten wrote:
> "\xbb" in the charset iso8859-1 (aka latin1) or  is this lovely symbol 
> here, "»". I know this, since I've sent myself an email containing 
> this little character and used iso8859-1 as the encoding.
>
> I then download the email using python poplib library.
>
> *>>>* import poplib
> *>>>* mailbox = poplib.POP3_SSL('pop.gmail.com 
> <http://pop.gmail.com>', port=995)
> *>>>* mailbox.user('[email protected] <mailto:[email protected]>')
> '+OK send PASS'
> *>>>* mailbox.pass_('mypassword')
> '+OK Welcome.'
> *>>>* msg = mailbox.retr(3) # email no. 3 is the relevant email.
> *>>>* msg_lines = msg[1]
> *>>>* msg_lines[29] # this is the line that contains the "»"
> '=BB'
> *>>>* len(msg_lines[29])
> 3
>
> Instead of =BB I expected to see \xbb. To me, the innocent user of 
> poplib, I would say there must be a bug there. However, knowing I 
> don't fully understand all the charset encoding stuff I'm sure poplib 
> is sound and I'm the one that's mistaken. I've used another mail 
> client to download the same file and it renders in correctly when the 
> encoding is set to latin1.
>
> As far as I can tell, I can't exactly convert "=BB" to another encoding. 
>
> >>> print '\xBB'.decode('latin1')
> »
> >>> print '=BB'.decode('latin1')
> =BB
>
> I've tried sending utf-8 encoded emails too, but it has the same 
> result, albeit showing '=C2=BB' instead of '=BB'. What can I do to 
> successfully decode the email after downloading it with poplib?
>
> Tim ^,^
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Python Ireland" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.ie/group/pythonireland?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to