Printing UTF-8 mail to terminal

Liste des GroupesRevenir à cl python 
Sujet : Printing UTF-8 mail to terminal
De : loris.bennett (at) *nospam* fu-berlin.de (Loris Bennett)
Groupes : comp.lang.python
Date : 31. Oct 2024, 16:33:41
Autres entêtes
Organisation : FUB-IT, Freie Universität Berlin
Message-ID : <878qu49tii.fsf@zedat.fu-berlin.de>
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Hi,

I have a command-line program which creates an email containing German
umlauts.  On receiving the mail, my mail client displays the subject and
body correctly:

  Subject: Übung

  Sehr geehrter Herr Dr. Bennett,

  Dies ist eine Übung.

So far, so good.  However, when I use the --verbose option to print
the mail to the terminal via

  if args.verbose:
      print(mail)

I get:

  Subject: Übungsbetreff

  Sehr geehrter Herr Dr. Bennett,

  Dies ist eine =C3=9Cbung.

What do I need to do to prevent the body from getting mangled?

I seem to remember that I had issues in the past with a Perl version of
a similar program.  As far as I recall there was an issue with fact the
greeting is generated by querying a server, whereas the body is being
read from a file, which lead to oddities when the two bits were
concatenated.  But that might just have been a Perl thing.

Cheers,

Loris

--
This signature is currently under constuction.

Date Sujet#  Auteur
31 Oct 24 * Printing UTF-8 mail to terminal17Loris Bennett
31 Oct 24 +* Re: Printing UTF-8 mail to terminal4Left Right
1 Nov 24 i`* Re: Printing UTF-8 mail to terminal3Loris Bennett
3 Nov 24 i `* Re: Printing UTF-8 mail to terminal2Inada Naoki
4 Nov 24 i  `- Re: Printing UTF-8 mail to terminal1Loris Bennett
31 Oct 24 +- Re: Printing UTF-8 mail to terminal (Posting On Python-List Prohibited)1Lawrence D'Oliveiro
31 Oct 24 `* Re: Printing UTF-8 mail to terminal11Cameron Simpson
1 Nov 24  `* Re: Printing UTF-8 mail to terminal10Loris Bennett
1 Nov 24   +* Re: Printing UTF-8 mail to terminal8Loris Bennett
1 Nov 24   i+- Re: Printing UTF-8 mail to terminal1dieter.maurer
1 Nov 24   i`* Re: Printing UTF-8 mail to terminal6Cameron Simpson
4 Nov 24   i `* Re: Printing UTF-8 mail to terminal5Loris Bennett
4 Nov 24   i  `* Re: Printing UTF-8 mail to terminal4Loris Bennett
4 Nov 24   i   `* Re: Printing UTF-8 mail to terminal3Loris Bennett
5 Nov 24   i    +- Re: Printing UTF-8 mail to terminal1Peter J. Holzer
5 Nov 24   i    `- Re: Printing UTF-8 mail to terminal1Cameron Simpson
1 Nov 24   `- Re: Printing UTF-8 mail to terminal1Cameron Simpson

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal