Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 28 |
Nodes: | 6 (0 / 6) |
Uptime: | 43:49:28 |
Calls: | 422 |
Calls today: | 1 |
Files: | 1,024 |
Messages: | 90,211 |
I wasn't able to respond until now.
Currently I'm happy with the workaround using "clipboard get" instead of twapi equivalent command.
Stil one might suspect a bug in twapi. I would expect that twapi can
best handle the Windows clipboard.
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.
Am 21.03.2025 um 21:15 schrieb alexandru:
I wasn't able to respond until now.
Currently I'm happy with the workaround using "clipboard get" instead of
twapi equivalent command.
Stil one might suspect a bug in twapi. I would expect that twapi can
best handle the Windows clipboard.
TWAPI gives you more control.
But you should know what you do.
In your use case (text transmission), the native clipboard code is IMHO
best suited.
If you want to do enhanced things (transmit images, whatever), use TWAPI.
Take care,
Harald
I'm accessing the Windows clipboard using twapi.
When the text in the clipboard was copied from an MS Excel cell, then
text contains some new line char that I could not identify and thus
unable to remove it using
regsub {[\r\n]+$} $text ""
What other way are there besides "string trim" to remove new line chars?
Many thanks
Alexandru
--
I'm accessing the Windows clipboard using twapi.
When the text in the clipboard was copied from an MS Excel cell, then
text contains some new line char that I could not identify and thus
unable to remove it using
regsub {[\r\n]+$} $text ""
What other way are there besides "string trim" to remove new line chars?
Many thanks
Alexandru
--
Well, that's what my orginal reexp does. No effect.
regsub {[\r\n]+$} $text ""
string map "\n {} \r {}" $text
I'm accessing the Windows clipboard using twapi.Could this be an encoding issue? I remember that the default output from
When the text in the clipboard was copied from an MS Excel cell, then
text contains some new line char that I could not identify and thus
unable to remove it using
regsub {[\r\n]+$} $text ""
What other way are there besides "string trim" to remove new line chars?
Many thanks
Alexandru
--
Harold suggested:
string map "\n {} \r {}" $text
This deletes every occurrence of \n and every occurrence of \r,
anywhere in the string.
Which is very different.
so, does not
regsub {\x00$} $text {} text_sans_nul
do what you want?
-mike
Hi Alexandru,
please allow me to share this wish 8.6.14 32 bit session:
Excel 2013 with a cell with the content "AÄ".
AÄ
% clipboard get
AÄ
% lmap i [split $c ""] {scan $i %c}
65 196 10
% string trimright $c "\x0a"
AÄ
%
So, "string trimright \x0a" does the job for me.
Take care,
Harald
I tried
set text [encoding convertfrom cp1252 $text]
but no success.
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.
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.
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.
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.