Re: Printing UTF-8 mail to terminal

Liste des GroupesRevenir à cl python 
Sujet : Re: Printing UTF-8 mail to terminal
De : loris.bennett (at) *nospam* fu-berlin.de (Loris Bennett)
Groupes : comp.lang.python
Date : 04. Nov 2024, 12:48:15
Autres entêtes
Organisation : FUB-IT, Freie Universität Berlin
Message-ID : <87a5efmg0g.fsf@zedat.fu-berlin.de>
References : 1 2 3 4 5 6
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Inada Naoki <songofacandy@gmail.com> writes:

2024年11月2日(土) 0:36 Loris Bennett via Python-list <python-list@python.org>:
>
Left Right <olegsivokon@gmail.com> writes:
>
There's quite a lot of misuse of terminology around terminal / console
/ shell.  Please, correct me if I'm wrong, but it looks like you are
printing that on MS Windows, right?  MS Windows doesn't have or use
terminals (that's more of a Unix-related concept). And, by "terminal"
I mean terminal emulator (i.e. a program that emulates the behavior of
a physical terminal). You can, of course, find some terminal programs
for windows (eg. mintty), but I doubt that that's what you are dealing
with.
>
What MS Windows users usually end up using is the console.  If you
run, eg. cmd.exe, it will create a process that displays a graphical
console.  The console uses an encoding scheme to represent the text
output.  I believe that the default on MS Windows is to use some
single-byte encoding. This answer from SE family site tells you how to
set the console encoding to UTF-8 permanently:
>
https://superuser.com/questions/269818/change-default-code-page-of-windows-console-to-utf-8
, which, I believe, will solve your problem with how the text is
displayed.
>
I'm not using MS Windows.  I am using a Gnome terminal on Debian 12
locally and connecting via SSH to a AlmaLinux 8 server, where I start a
tmux session.
>
On Thu, Oct 31, 2024 at 5:19 PM Loris Bennett via Python-list
<python-list@python.org> wrote:
>
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.
>
>
Try PYTHONUTF8=1 envver.
>

This does not seem to affect the way the email body is printed.

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