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


Groups > comp.lang.python > #196938

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:44:18 +1100
Lines 41
Message-ID <mailman.68.1730497471.4695.python-list@python.org> (permalink)
References <87msijo2cd.fsf@zedat.fu-berlin.de> <ZyVLsn2l9jJ2Fikl@cskk.homeip.net>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
X-Trace news.uni-berlin.de icP4HYD7+Der+lEcbh569w+15SjMeNSXwW9qvy68AQ8A==
Cancel-Lock sha1:FvwwmjqROz2Z0JgkRkJAFKzDheM= sha256:mJG7vIw5gvx9B2dJrL8P3MC4HgYFZN1DlVBOLr3WqEM=
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; 'text/plain;': 0.07; 'cc:addr:python-list': 0.09; 'parse': 0.09; 'skip:` 20': 0.09; 'writes:': 0.09; 'yes.': 0.09; 'cc:no real name:2**0': 0.14; 'bennett': 0.16; 'dies': 0.16; 'encoding': 0.16; 'encoding.': 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; 'obtained.': 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; 'right.': 0.16; 'simpson': 0.16; 'skip:> 10': 0.16; 'sorted': 0.16; 'wrote:': 0.16; 'problem': 0.16; 'python': 0.16; 'cc:addr:python.org': 0.20; 'way.': 0.22; 'code': 0.23; "i'd": 0.24; 'actual': 0.25; 'cc:2**0': 0.25; 'seems': 0.26; 'object': 0.26; 'suspect': 0.26; 'expect': 0.28; 'thinking': 0.28; 'example,': 0.28; 'header:User-Agent:1': 0.30; 'printed': 0.31; 'approach': 0.31; 'module': 0.31; 'raw': 0.32; 'but': 0.32; 'header:In-Reply-To:1': 0.34; 'same': 0.34; 'meaning': 0.35; 'received:au': 0.35; 'yes,': 0.35; 'display': 0.36; '...': 0.37; 'using': 0.37; 'could': 0.37; 'example': 0.37; 'file': 0.38; 'way': 0.38; 'happen': 0.40; 'should': 0.40; "there's": 0.61; 'forward': 0.62; 'subject': 0.63; 'email': 0.63; 'me.': 0.64; 'received:13': 0.64; 'received:userid': 0.66; 'body': 0.67; 'skip:e 20': 0.67; 'right': 0.68; 'following:': 0.69; 'ist': 0.69; 'out.': 0.80; 'leads': 0.81; 'client': 0.82; 'code)': 0.84; 'transcribe': 0.84; 'subject:UTF': 0.91; 'subject:mail': 0.95
Mail-Followup-To Loris Bennett <loris.bennett@fu-berlin.de>, python-list@python.org
Content-Disposition inline
In-Reply-To <87msijo2cd.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 <ZyVLsn2l9jJ2Fikl@cskk.homeip.net>
X-Mailman-Original-References <87msijo2cd.fsf@zedat.fu-berlin.de>
Xref csiph.com comp.lang.python:196938

Show key headers only | View raw


On 01Nov2024 08:11, Loris Bennett <loris.bennett@fu-berlin.de> wrote:
>Cameron Simpson <cs@cskk.id.au> writes:
>> If you're using the Python email module to parse (or construct) the
>> message as a `Message` object I'd expect that to happen automatically.
>
>I am using
>  email.message.EmailMessage

Noted. That seems like the correct approach to me.

>And you are right that encoding for the actual mail which is received 
>is
>automatically sorted out.  If I display the raw email in my client I get
>the following:
>
>  Content-Type: text/plain; charset="utf-8"
>  Content-Transfer-Encoding: quoted-printable
>  ...
>  Subject: =?utf-8?q?=C3=9Cbungsbetreff?=
>  ...
>  Dies ist eine =C3=9Cbung.

Right. Quoted-printable encoding for the transport.

>I would interpret that as meaning that the subject and body are encoded
>in the same way.

Yes.

>The problem just occurs with the unsent string representation printed to
>the terminal.

Yes, and I was thinking abut this yesterday. I suspect that 
`print(some_message_object)` is intended to transcribe it for transport.  
For example, one could write to an mbox file and just print() the 
message into it and get correct transport/storage formatting, which 
includes the qp encoding.

Can you should the code (or example code) which leads to the qp output?  
I suspect there's a straight forward way to get the decoded Unicode, but 
I'd need to see how what you've got was obtained.

Back to comp.lang.python | Previous | NextPrevious 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