Paste new button, ANSI and Unicode clipboard data

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

User avatar
milo1012
Power Member
Power Member
Posts: 1158
Joined: 2012-02-02, 19:23 UTC

Post by *milo1012 »

2MVV
I think it's obvious (and I really don't want to take a look into the Firefox source): Chromium and many other apps use a single CF_UNICODETEXT set and don't do anything else, Windows does the automatic conversion.
Firefox (and BTW, it seems also Opera 12.x for CF_TEXT) seems to use two steps: First set CF_UNICODETEXT, then (although Windows does the automatic conversion) do a 2nd step and set CF_TEXT themselves, which will override the previous automatically generated CF_TEXT.
It's enough to rely on the system codepage by doing a conversion with:

Code: Select all

WideCharToMultiByte(CP_ACP, 0, wstring, wstring_length, outbuffer, outbuffer_length, NULL, NULL);
so in your case CP_ACP will be 1251, and so you will get the correct CF_TEXT output.


MVV wrote:That's correct, and I talk about two terms: system default codepage and keyboard layout.
Sure, but this whole "Locale" Windows terminology is quite a mess, so I wanted to make sure that other people will understand it clearly.
Like I said, the "Language for non-Unicode Programs" setting is probably not the same as a true Russian Windows, so I assumed you (or the OP) didn't have the 1251 page set.




Update:
A small test tool which will show the system codepages, the user and input locale, and copies text from commandline to clipboard, either with additional CF_TEXT correctly recoded with system cp (after CF_UNICODETEXT) or without it. This pretty much confirms what I wrote earlier.

Code: Select all

MIME-Version: 1.0
Content-Type: application/octet-stream; name="clipboard_test.rar"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="clipboard_test.rar"

UmFyIRoHADvQcwgADQAAAAAAAAC9gnSAgCcAsgMAAHIJAAACKArS8XUbd0odNQcAICAAAGNiYy5j
cHCnGCNIBhzCy6OC3XjiZcY/JKkUySSTRrF36+37LUW1zBXmD3znUoEp8rnJnq/kIyL+9qSRS5qF
akCC0B0jxynuOwQKf8r9fSBFMCjGzlfUBuuIT8iFeFgyco2me5podM89vvP9cei3xoVI8TU3Bkn8
bltWxX0rlGgTqaChqverwLyjoS6dLdOHHxhI3L5ILwzir/vEJebqI4LT9UTqT90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VNik3YZpJJTdSbEmEx8enbd3X/52gSAGNK0q2GvJWQd3g2Z4AaXm
bR2zCxxnADUhLvbKcwD9DcP+vsXNQxOoHVH698le8PYsEHlPjn4BLHptIFzS+CzxLgh8KPwwyGZz
Rs8BP7fGZem6zLijYY7/8eNwv5eh3D/M4Z++Osn9Qwki3lFO2Jm8fjw4hT7igld8n/TX3DUdn/5G
uEGYQE3hd7JueG4LgfA9VVaVcYfGYseAeqpxOOLINhE9oZLO6Qf+zCWf7k4rPQGJzIoXprPkf37x
d7bh3ySlYU14tI7Dq/h2lSK3E1whHw5J7fU1ZWTSvG8iWWnpxmKYCcU6rUI00HJiNd8fMktLO8YM
DZoHqA0RguFqBuQWAHISa1v8oHMyvC5tUhTOC6ayVQ4Qp3e9rFIa5tkS87FE+w6ZYT7OUH6p9daU
dzNy1mhPyunbtuQfyGbqTs/0JASugXu3O6Nn8UHbcJx+5k27S/JMxMP/32gIdZKq0PZHbq+M6rfH
4YuXevWc8t3/sPOvgUQxeEJLMjQHye2zERAFoA23XP6gqBQR3gwpxU4fqm09Qt8YSTnCCx220MKm
f2DNCdDwpd4wP7Bzpw0uEFyM41Tr29G5UhiZoecge9KDhENPL7hxn2HQNw240JqDLsTqv7+boReT
vf/l24/BNB6ps7G+EnfhtLI6FOi0Ex28nUf06INNW8Tq0+LO8SC5sUl0AL+IZ/ap/9TEPXsAQAcA
TC plugins: PCREsearch and RegXtract
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Well, the solution would be to use CF_UNICODETEXT, but this may break compatibility when copying buttons between different versions of TC...
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I don't think that you break anything by pasting CF_UNICODETEXT first and copying in both CF_UNICODETEXT and CF_TEXT. Older versions will copy and paste CF_TEXT.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The problem is that currently characters from different codepages are encoded within CF_TEXT as UTF-8-BOM plus UTF-8 text...
Author of Total Commander
https://www.ghisler.com
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Post by *DrShark »

HISTORY.TXT wrote:07.05.17 Added: Paste button to button bar: accept also Unicode text directly (32/64)
Now pasting the cyrillic text to TC button from apps that copy as CF_UNICODETEXT (like Chromium-like browsers) seems to work correct.

Additionally, the old TC 9.0a paste method (ANSI) available for apps that copy text only as CF_TEXT (Ulister plugin is the example of such app) via holding the Shift key while pressing the Paste button bar context menu item. Of course Christian would prefer to detect such clipboard content to paste it correctly without holding Shift, but since I don't enough have the knowledge on subject (though I doubt it's possible because even Akelpad can't autodetect it), we decided it's better to ask here for possible solution. Christian's possible ideas (from email):
Christian Ghisler wrote:OK, I have now added that the new method is disabled when shift isn't pressed.
Is there any way to detect this invalid clipboard data?
I can see with EnumClipboardFormats whether the other program was setting CF_UNICODETEXT or CF_TEXT when copying to the clipboard, so I could use the Unicode text only in the first case.
But some apps may set CF_TEXT and also CF_LOCALE - then
the Unicode text would be the valid one too! But even if CF_LOCALE isn't set, it is listed as available by EnumClipboardFormats, and it's set to the current user locale. Any ideas?
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

DrShark,
Move to Fixed bugs?

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Post by *DrShark »

Hacker wrote:DrShark,
Move to Fixed bugs?
Well, the issue with Chrome browser reported here: http://ghisler.ch/board/viewtopic.php?p=326757#326757 is fixed. But this fix created the new issue (which didn't exist in TC 9.0a) with pasting cyrillic data from apps that copy to CF_TEXT (for now solved in 9.10 by introducing Shift+Paste feature). I'm not sure whether it's is required to create the topic on new issue in Bug reports or TC English or Suggestions forum, maybe it's better to wait for Christian's decision. This topic may be splitted later if necessary.
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

You can hold down Shift to paste text with the old method.
Author of Total Commander
https://www.ghisler.com
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Post by *DrShark »

2Hacker
I think you can move it to fixed bugs. If someone knows and will want to share a reliable solution to detect the incorrect ANSI clipboard content (to get rid of this Shift+Paste workaround,) one can either post it here in this topic or contact TC author directly by email.
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
Post Reply