Re: Printing UTF-8 mail to terminal

2024-11-05 Thread Cameron Simpson via Python-list
On 04Nov2024 13:02, Loris Bennett wrote: OK, so I can do: ## if args.verbose: for k in mail.keys(): print(f"{k}: {mail.get(k)}") print('') print(mail.get_content()) ##

Re: Printing UTF-8 mail to terminal

2024-11-05 Thread Peter J. Holzer via Python-list
On 2024-11-04 13:02:21 +0100, Loris Bennett via Python-list wrote: > "Loris Bennett" writes: > > "Loris Bennett" writes: > >> Cameron Simpson writes: > >>> On 01Nov2024 10:10, Loris Bennett wrote: > as expected. The non-UTF-8 text occurs when I do > > mail = EmailMessage() > >>>

Re: Printing UTF-8 mail to terminal

2024-11-04 Thread Loris Bennett via Python-list
"Loris Bennett" writes: > "Loris Bennett" writes: > >> Cameron Simpson writes: >> >>> On 01Nov2024 10:10, Loris Bennett wrote: as expected. The non-UTF-8 text occurs when I do mail = EmailMessage() mail.set_content(body, cte="quoted-printable") ... if arg

Re: Printing UTF-8 mail to terminal

2024-11-04 Thread Loris Bennett via Python-list
"Loris Bennett" writes: > Cameron Simpson writes: > >> On 01Nov2024 10:10, Loris Bennett 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) >>> >>>

Re: Printing UTF-8 mail to terminal

2024-11-04 Thread Loris Bennett via Python-list
Inada Naoki writes: > 2024年11月2日(土) 0:36 Loris Bennett via Python-list : > >> Left Right 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 W

Re: Printing UTF-8 mail to terminal

2024-11-04 Thread Loris Bennett via Python-list
Cameron Simpson writes: > On 01Nov2024 10:10, Loris Bennett 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. >> >>T

Re: Printing UTF-8 mail to terminal

2024-11-02 Thread Inada Naoki via Python-list
Try PYTHONUTF8=1 envver. 2024年11月2日(土) 0:36 Loris Bennett via Python-list : > Left Right 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 Windo

Re: Printing UTF-8 mail to terminal

2024-11-02 Thread Eli the Bearded via Python-list
In comp.lang.python, Gilmeh Serda wrote: > Python 3.12.6 (main, Sep 8 2024, 13:18:56) [GCC 14.2.1 20240805] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> help('modules') > > Please wait a moment while I gather a list of all available modules... > > Ass

Re: Printing UTF-8 mail to terminal

2024-11-02 Thread Jon Ribbens via Python-list
On 2024-11-01, Eli the Bearded <*@eli.users.panix.com> wrote: > In comp.lang.python, Gilmeh Serda wrote: >> Python 3.12.6 (main, Sep 8 2024, 13:18:56) [GCC 14.2.1 20240805] on linux >> Type "help", "copyright", "credits" or "license" for more information. >> >>> help('modules') >> >> Please wai

Re: Printing UTF-8 mail to terminal

2024-11-02 Thread Barry via Python-list
> On 1 Nov 2024, at 22:57, Left Right wrote: > > Does this Windows Terminal support the use > of programs like tmux? I have not tried, but should work. Best to install the terminal app from the MS app store. Most use I make is to ssh into linux systems and stuff like editors. Colour output a

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Left Right via Python-list
> Windows does now. They implemented this feature over the last few years. > Indeed they took inspiration from how linux does this. > > You might find https://devblogs.microsoft.com/commandline/ has interesting > articles about this. I don't have MS Windows. My wife does, but I don't want to both

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Barry via Python-list
> On 31 Oct 2024, at 16:42, Left Right via Python-list > wrote: > > MS Windows doesn't have or use > terminals (that's more of a Unix-related concept). Windows does now. They implemented this feature over the last few years. Indeed they took inspiration from how linux does this. You might f

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Cameron Simpson via Python-list
On 31Oct2024 21:53, alan.ga...@yahoo.co.uk wrote: On 31/10/2024 20:50, Cameron Simpson via Python-list wrote: If you're just dealing with this directly, use the `quopri` stdlib module: https://docs.python.org/3/library/quopri.html One of the things I love about this list are these little feat

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Cameron Simpson via Python-list
On 01Nov2024 10:10, Loris Bennett 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 t

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Cameron Simpson via Python-list
On 01Nov2024 08:11, Loris Bennett wrote: Cameron Simpson 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

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Dieter Maurer via Python-list
Loris Bennett wrote at 2024-11-1 10:10 +0100: > ... > mail.set_content(body, cte="quoted-printable") In the line above, you request the content to use the "cte" (= "Content-Transfer-Encoding") "quoted-printable" and consequently, the content is encoded with `quoted-printable`. Maybe, you do not n

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Loris Bennett via Python-list
Cameron Simpson writes: > On 31Oct2024 16:33, Loris Bennett wrote: >>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: > [...] >>So far, so good. However, when I use the --verbose o

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Loris Bennett via Python-list
Left Right 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 "te

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Loris Bennett via Python-list
"Loris Bennett" writes: > Cameron Simpson writes: > >> On 31Oct2024 16:33, Loris Bennett wrote: >>>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: >> [...] >>>So far, so good.

Re: Printing UTF-8 mail to terminal

2024-10-31 Thread Alan Gauld via Python-list
On 31/10/2024 20:50, Cameron Simpson via Python-list wrote: > That looks to me like quoted-printable. This is an encoding for binary > transport of text to make it robust against not 8-buit clean ... > If you're just dealing with this directly, use the `quopri` stdlib > module: https://docs.py

Re: Printing UTF-8 mail to terminal

2024-10-31 Thread Cameron Simpson via Python-list
On 31Oct2024 16:33, Loris Bennett wrote: 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: [...] So far, so good. However, when I use the --verbose option to print the mail to the ter

Re: Printing UTF-8 mail to terminal

2024-10-31 Thread Left Right via Python-list
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 emula

Printing UTF-8 mail to terminal

2024-10-31 Thread Loris Bennett via Python-list
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 opti

Re: Printing UTF-8

2006-09-21 Thread John Machin
[EMAIL PROTECTED] wrote: > I am new to unicode so please bear with my stupidity. > > I am doing the following in a Python IDE called Wing with Python 23. > > >>> s = "äöü" >From later evidence, this string is encoded as utf-8. Looks like Wing must be using an implicit "# coding: utf-8" for interac

Printing UTF-8

2006-09-21 Thread sheldon . regular
I am new to unicode so please bear with my stupidity. I am doing the following in a Python IDE called Wing with Python 23. >>> s = "äöü" >>> print s äöü >>> print s äöü >>> s '\xc3\xa4\xc3\xb6\xc3\xbc' >>> s.decode('utf-8') u'\xe4\xf6\xfc' >>> u = s.decode('utf-8') >>> u u'\xe4\xf6\xfc' >>>