Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #196939

Re: Printing UTF-8 mail to terminal

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Cameron Simpson <cs@cskk.id.au>
Newsgroups comp.lang.python
Subject Re: Printing UTF-8 mail to terminal
Date Sat, 2 Nov 2024 08:47:39 +1100
Lines 23
Message-ID <mailman.69.1730497664.4695.python-list@python.org> (permalink)
References <875xp7nwus.fsf@zedat.fu-berlin.de> <ZyVMe3Jspc0fJrel@cskk.homeip.net>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
X-Trace news.uni-berlin.de aiGkdu7mnBlC+QpbtciATQM7CP9PzZlKXCabZx5ABdCg==
Cancel-Lock sha1:0D12DiuWhBmeStqJ0I7xYwzKgns= sha256:HzT96hZXHpHL9RF1EoAIDjF2IBOYjROoIoDVQ3LdPZI=
Return-Path <cameron@cskk.id.au>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
Authentication-Results mail.python.org; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'string': 0.07; 'cc:addr :python-list': 0.09; 'cc:no real name:2**0': 0.14; 'that.': 0.15; 'bennett': 0.16; 'conversion': 0.16; 'expected.': 0.16; 'from:addr:cs': 0.16; 'from:addr:cskk.id.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'objective': 0.16; 'presumably': 0.16; 'received:13.237': 0.16; 'received:13.237.201': 0.16; 'received:13.237.201.189': 0.16; 'received:cskk.id.au': 0.16; 'received:id.au': 0.16; 'received:mail.cskk.id.au': 0.16; 'skip:> 10': 0.16; 'unicode': 0.16; 'wrote:': 0.16; 'python': 0.16; 'cc:addr:python.org': 0.20; 'cc:2**0': 0.25; 'object': 0.26; 'header:User-Agent:1': 0.30; 'question': 0.32; 'obtain': 0.32; 'header:In-Reply-To:1': 0.34; 'received:au': 0.35; '...': 0.37; 'necessary': 0.39; 'text': 0.39; 'otherwise': 0.39; 'still': 0.40; 'skip:m 20': 0.63; 'received:13': 0.64; 'received:userid': 0.66; 'body': 0.67; 'order': 0.69; 'subject:UTF': 0.91; 'subject:mail': 0.95; 'turned': 0.95
Mail-Followup-To Loris Bennett <loris.bennett@fu-berlin.de>, python-list@python.org
Content-Disposition inline
In-Reply-To <875xp7nwus.fsf@zedat.fu-berlin.de>
User-Agent Mutt/2.2.13 (2024-03-09)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.39
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <https://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <ZyVMe3Jspc0fJrel@cskk.homeip.net>
X-Mailman-Original-References <875xp7nwus.fsf@zedat.fu-berlin.de>
Xref csiph.com comp.lang.python:196939

Show key headers only | View raw


On 01Nov2024 10:10, Loris Bennett <loris.bennett@fu-berlin.de> wrote:
>as expected.  The non-UTF-8 text occurs when I do
>
>  mail = EmailMessage()
>  mail.set_content(body, cte="quoted-printable")
>  ...
>
>  if args.verbose:
>      print(mail)
>
>which is presumably also correct.
>
>The question is: What conversion is necessary in order to print the
>EmailMessage object to the terminal, such that the quoted-printable
>parts are turned (back) into UTF-8?

Do you still have access to `body` ? That would be the original message 
text? Otherwise maybe:

     print(mail.get_content())

The objective is to obtain the message body Unicode text (i.e. a regular 
Python string with the original text, unencoded). And to print that.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Printing UTF-8 mail to terminal "Loris Bennett" <loris.bennett@fu-berlin.de> - 2024-10-31 16:33 +0100
  Re: Printing UTF-8 mail to terminal Left Right <olegsivokon@gmail.com> - 2024-10-31 17:38 +0100
    Re: Printing UTF-8 mail to terminal "Loris Bennett" <loris.bennett@fu-berlin.de> - 2024-11-01 07:52 +0100
      Re: Printing UTF-8 mail to terminal Inada Naoki <songofacandy@gmail.com> - 2024-11-03 12:08 +0900
        Re: Printing UTF-8 mail to terminal "Loris Bennett" <loris.bennett@fu-berlin.de> - 2024-11-04 11:48 +0100
  Re: Printing UTF-8 mail to terminal (Posting On Python-List Prohibited) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-10-31 19:35 +0000
  Re: Printing UTF-8 mail to terminal Cameron Simpson <cs@cskk.id.au> - 2024-11-01 07:50 +1100
    Re: Printing UTF-8 mail to terminal "Loris Bennett" <loris.bennett@fu-berlin.de> - 2024-11-01 08:11 +0100
      Re: Printing UTF-8 mail to terminal "Loris Bennett" <loris.bennett@fu-berlin.de> - 2024-11-01 10:10 +0100
        Re: Printing UTF-8 mail to terminal dieter.maurer@online.de - 2024-11-01 17:38 +0100
        Re: Printing UTF-8 mail to terminal Cameron Simpson <cs@cskk.id.au> - 2024-11-02 08:47 +1100
          Re: Printing UTF-8 mail to terminal "Loris Bennett" <loris.bennett@fu-berlin.de> - 2024-11-04 11:44 +0100
            Re: Printing UTF-8 mail to terminal "Loris Bennett" <loris.bennett@fu-berlin.de> - 2024-11-04 11:57 +0100
              Re: Printing UTF-8 mail to terminal "Loris Bennett" <loris.bennett@fu-berlin.de> - 2024-11-04 13:02 +0100
                Re: Printing UTF-8 mail to terminal "Peter J. Holzer" <hjp-python@hjp.at> - 2024-11-05 21:39 +0100
                Re: Printing UTF-8 mail to terminal Cameron Simpson <cs@cskk.id.au> - 2024-11-06 08:20 +1100
      Re: Printing UTF-8 mail to terminal Cameron Simpson <cs@cskk.id.au> - 2024-11-02 08:44 +1100

csiph-web