Re: Remove new line char

Liste des GroupesRevenir à cl tcl 
Sujet : Re: Remove new line char
De : apnmbx-public (at) *nospam* yahoo.com (Ashok)
Groupes : comp.lang.tcl
Date : 24. Mar 2025, 04:01:48
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vrqhus$3qsb2$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Mozilla Thunderbird
To get *text* from the clipboard using twapi, use twapi::read_clipboard_text, not twapi::read_clipboard.
As has been pointed out by others, Alexandru's issue is he is using [read_clipboard 1] which returns raw binary data in a specific encoding. The encoding itself is stored as CF_LOCALE clipboard format in the clipboard. To work correctly, the code would need to
- retrieve the encoded text using [read_clipboard 1]
- retrieve CF_LOCALE
- Map CF_LOCALE to the appropriate Tcl encoding
- Use [encoding] to decode the data into text
And even that is not guaranteed to work because the default CF_LOCALE encoding setting may not support all the Unicode characters pasted into the clipboard if the paster had used the CF_UNICODETEXT (13) format.
So either use Tcl's "clipboard get" or twapi's "read_clipboard_text". If insisting on using "read_clipboard" for whatever reason, use "read_clipboard 13" to read in UTF-16 encoding and then [encoding convertfrom unicode $clipdata].
Hope that clarifies
/Ashok
On 3/23/2025 6:22 PM, Harald Oehlmann wrote:
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

Date Sujet#  Auteur
19 Mar 25 * Remove new line char23alexandru
19 Mar 25 +* Re: Remove new line char4Ralf Fassel
19 Mar 25 i`* Re: Remove new line char3alexandru
19 Mar 25 i `* Re: Remove new line char2Michael Soyka
20 Mar 25 i  `- Re: Remove new line char1alexandru
19 Mar 25 +- Re: Remove new line char1Arjen
19 Mar 25 +* Re: Remove new line char16Harald Oehlmann
19 Mar 25 i`* Re: Remove new line char15alexandru
19 Mar 25 i +- Re: Remove new line char1alexandru
19 Mar 25 i `* Re: Remove new line char13Rich
20 Mar 25 i  `* Re: Remove new line char12alexandru
20 Mar 25 i   `* Re: Remove new line char11alexandru
20 Mar 25 i    +* Re: Remove new line char9Harald Oehlmann
20 Mar 25 i    i`* Re: Remove new line char8alexandru
20 Mar 25 i    i `* Re: Remove new line char7Rich
21 Mar 25 i    i  `* Re: Remove new line char6Harald Oehlmann
21 Mar 25 i    i   `* Re: Remove new line char5Rich
21 Mar 25 i    i    +* Re: Remove new line char3alexandru
23 Mar 25 i    i    i`* Re: Remove new line char2Harald Oehlmann
24 Mar 25 i    i    i `- Re: Remove new line char1Ashok
23 Mar 25 i    i    `- Re: Remove new line char1Harald Oehlmann
20 Mar 25 i    `- Re: Remove new line char1Michael Soyka
20 Mar 25 `- Re: Remove new line char1Simon Geard

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal