Sujet : Re: Remove new line char
De : wortkarg3 (at) *nospam* yahoo.com (Harald Oehlmann)
Groupes : comp.lang.tclDate : 23. Mar 2025, 13:54:56
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vrp0b0$2cnm7$2@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11
User-Agent : Mozilla Thunderbird
Am 21.03.2025 um 13:59 schrieb Rich:
Harald Oehlmann <wortkarg3@yahoo.com> wrote:
Am 20.03.2025 um 19:03 schrieb Rich:
alexandru <alexandru.dadalau@meshparts.de> wrote:
I tried
>
set text [encoding convertfrom cp1252 $text]
>
but no success.
>
Are you sure the clipboard is cp1252?
>
If it is utf-8 then converting as if it is cp1252 will create strange
results.
>
Dear Rich,
the Windows clipboard is more complicated/sophisticated.
Yes, that I am well aware.
Each entry has a type. This is nowdays mostly CF_UNICODETEXT, which is
16 bit unicode.
A sending application can put an entry into the clipboard in multiple
formats and the receiving application can pick one or more.
Yes, but alexandru's example he posted, he's not picking a format from
the clipboard, he's assuming it was cp1252 and forcefully decoding it
as if it was cp1252. If he left out telling us he requested cp1252
from the clipboard then that's on him.
We have often "enhanced" this code in TCL to adopt it to modern
usage. There should not be any issues with the encoding, expect that
the sending application does anything strange.
This is good, because handling the clipboard on windows is an ugly
beast. My comment was to what alexandru posted showing simply forcing
a decode as if what he got was cp1252, without showing he asked the
clipboard to supply cp1252 data.
Thanks Rich, great.
You may look to the clipboard code in Tk and its history.
We often enhanced that.
I have answered Alexandru when to use what. I think, that is a good advice.
With TWAPI, you get raw data and you have to care (e.g. remove trailing zero, translate /n/r to /n). Tk native does that for you, but you have less control.
Take care,
Harald