Deutsch   English   Français   Italiano  
<mailman.68.1730497471.4695.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!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>
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>
Bytes: 5003

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.