I did some script in python that connects to GMAIL and print a email text... But, often my emails has words with "accent". And there is my problem...
For example a text that I got: "PLANO DE S=C3=9ADE" should be printed as "PLANO DE SAÚDE".
How can I turn legible my email text? What can I use to convert theses letters with accent?
Thanks,
The code suggested by Andrey, works fine on windows, but on Linux I still getting the wrong print:
>>> b = 'PLANO DE S=C3=9ADE'
>>> s = b.decode('quopri').decode('utf-8')
>>> print s
PLANO DE SÃDE
Rafael,
Thanks, you are correct about the word, it was misspelled. But the problem still the same here. Another example: CORRECT WORD: obersevação
>>> b = 'Observa=C3=A7=C3=B5es'
>>> s = b.decode('quopri').decode('utf-8')
>>> print s
Observações
I am using Debian with UTF-8 locale:
>>> :~$ locale
LANG=en_US.UTF-8
Andrey,
Thanks for your time. I agree with your explanation, but still with same problem here. Take look in my test:
s='Observa=C3=A7=C3=B5es'
s2= s.decode('quopri').decode('utf-8')
>>> print s
Observa=C3=A7=C3=B5es
>>> print s2
Observações
>>> import locale
>>> ENCODING = locale.getpreferredencoding()
>>> print s.encode(ENCODING)
Observa=C3=A7=C3=B5es
>>> print s2.encode(ENCODING)
Observações
>>> print ENCODING
UTF-8