'Regression for #12791 - Encode body correctly with other encodings
than utf-8'

def test_encoding(self):

    email = EmailMessage('Subject', 'Firstname    S\xc3\xbcrname    is    a    great    guy.', 'from@example.com', ['other@example.com'])
    email.encoding = 'iso-8859-1'
    message = email.message()
    self.assertMessageHasHeaders(message, {('MIME-Version', '1.0'), ('Content-Type', 'text/plain;    charset="iso-8859-1"'), ('Content-Transfer-Encoding', 'quoted-printable'), ('Subject', 'Subject'), ('From', 'from@example.com'), ('To', 'other@example.com')})
    self.assertEqual(message.get_payload(), 'Firstname    S=FCrname    is    a    great    guy.')
    text_content = 'Firstname    S\xc3\xbcrname    is    a    great    guy.'
    html_content = '<p>Firstname    S\xc3\xbcrname    is    a    <strong>great</strong>    guy.</p>'
    msg = EmailMultiAlternatives('Subject', text_content, 'from@example.com', ['to@example.com'])
    msg.encoding = 'iso-8859-1'
    msg.attach_alternative(html_content, 'text/html')
    payload0 = msg.message().get_payload(0)
    self.assertMessageHasHeaders(payload0, {('MIME-Version', '1.0'), ('Content-Type', 'text/plain;    charset="iso-8859-1"'), ('Content-Transfer-Encoding', 'quoted-printable')})
    self.assertTrue(payload0.as_bytes().endswith('\n\nFirstname    S=FCrname    is    a    great    guy.'))
    payload1 = msg.message().get_payload(1)
    self.assertMessageHasHeaders(payload1, {('MIME-Version', '1.0'), ('Content-Type', 'text/html;    charset="iso-8859-1"'), ('Content-Transfer-Encoding', 'quoted-printable')})
    self.assertTrue(payload1.as_bytes().endswith('\n\n<p>Firstname    S=FCrname    is    a    <strong>great</strong>    guy.</p>'))
