0

I have the following example string to make a function which will remove accents is an email header and I store it in the bd but since I get the header I get it that way

 ('Cotización pruebá ácentos')
    string = m['subject']

self.remove_accents(string.decode('utf-8'))

the function that I have is the following

def remove_accents(self, s):
    return ''.join(c for c in unicodedata.normalize('NFD', s) if 
             unicodedata.category(c) != 'Mn')

it removes the accents but it returns something like this

=?utf-8?b?q290axphy2nds24=?= =?utf-8?b?ihbydwviw6e

how do I decode the chain

  • 2
    `=?utf-8?b?q290axphy2nds24=?= =?utf-8?b?ihbydwviw6e` is encoded word encoding, used for encoding email headers. Your code does not produce this result using the string you provided. Please edit your question to provide an [mcve] – snakecharmerb Mar 29 '19 at 17:55
  • It is an email header and I store it in the bd but since I get the header I get it that way =?utf-8?b?q290axphy2nds24=?= =?utf-8?b?ihbydwviw6e – Palomita Yañez Quiroz Mar 29 '19 at 18:01
  • 1
    Try : `from email.header import decode_header _subject = decode_header(m['subject']) _subject = self.remove_accents(_subject.decode('utf-8')) ` – Lupitha Yañez C. Mar 29 '19 at 19:04

0 Answers0