E. Paine <paineeli...@gmail.com> added the comment:

Test example:

1) Open IDLE (shell or editor)
2) Copy some text in the IDLE window
3) Close the IDLE window (instance should end)
4) Paste into application of choice
Without the patch, the clipboard is cleared when the instance ends so nothing 
is pasted. With the patch, the content remains in the clipboard as expected.

Note: This is not a problem if clipboard history is turned on or the content is 
pasted before closure, however the order of events above is fairly common for 
me.


Encoding:

In the latest commit to the pull, I have changed the encoding from UTF-8 to 
UTF-16 and my reasoning is as follows:

1) Most importantly, using UTF-8, characters with a unicode value >=2^8 are 
incorrectly copied as multiple characters. UTF-8 does support these characters 
but uses a different number of bytes per character (which is presumably what is 
causing these issues - for example, "AĀ" is encoded as "\x41\xc4\x80", which 
pastes as "A─Ç") UTF-16, however, correctly works for all characters supported 
by Tcl (see next point).

2) "Strings in Tcl are encoded using 16-bit Unicode characters" 
(https://www.tcl.tk/man/tcl8.2.3/TclCmd/encoding.htm). Therefore, the encoding 
we choose should have at least 16 bits allocated per character (meaning either 
UTF-16 or UTF-32).

3) Windows' "Unicode-enabled functions [...] use UTF-16 (wide character) 
encoding, which is [...] used for native Unicode encoding on Windows operating 
systems" (https://docs.microsoft.com/en-us/windows/win32/intl/unicode). For me, 
this was what decided the new encoding (between the two given in the previous 
point).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40452>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to