Button is copied in wrong encoding with another layout

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

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Button is copied in wrong encoding with another layout

Post by *MVV »

E.g. I have buttonbar button with Russian hint. If I have EN keyboard layout active when copying button via context menu, TC copies button code in wrong encoding (even when I paste text into Unicode application, text is wrong), but if I switch to RU all is right.

Does TC copy button code in ANSI? Or why such bug occurs?

(TC 7.55 RC3)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48012
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

This is a known Windows bug: When you call SetClipboardData(CF_TEXT,..) and do not explicitly set the encoding, Windows seems to use the current keyboard layout for the encoding. Since TC ignores the encoding setting of the clipboard when you paste a button, this doesn't matter for copying/pasing buttons, it only matters when you want to paste the button details somewhere else.

I even have a fix for this bug in TC: Call SetClipBoarddata(CF_LOCALE,...). I just didn't use it in this function because it wasn't meant to copy button data anywhere else...
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 know it (that's because I guessed to change layout to see that all works fine with RU), but why TC can't copy Unicode text to clipboard? In this case all will work fine. If TC now is Unicoded, it should be easier to use wide strings instead of short ones.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48012
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

why TC can't copy Unicode text to clipboard?
I'm using UTF-8 for compatibility reasons, but only in fields which contain characters from other codepages.
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 understand. When you're copying text to clipboard, you can copy it in any encoding (just specify right one for clipboard format), and when you're pasting text from clipboard, you can choose in which encoding you want to see it, so it won't be a problem if you copy Unicode text in TC 7.55 and then try to paste it in local ANSI codepage in TC 7.04a e.g. - Windows will convert text for you (you just need to specify encoding).

{Get|Set}ClipboardData functions have format parameter that can be CF_TEXT for ANSI text and CF_UNICODETEXT for Unicode text, you can choose any of them for both functions and OS will do the rest. :)
luckylee
Junior Member
Junior Member
Posts: 2
Joined: 2014-03-21, 22:50 UTC

Post by *luckylee »

ghisler(Author) wrote:
why TC can't copy Unicode text to clipboard?
I'm using UTF-8 for compatibility reasons, but only in fields which contain characters from other codepages.
I believe UTF-8 is more universal encoding than Unicode.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

UTF-8 has some problems like length-size conversion etc. Also Windows API doesn't support it, it only supports Unicode (UTF-16) so text should be put into clipboard in UTF-16 in applications that support Unicode.
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Re: Button is copied in wrong encoding with another layout

Post by *DrShark »

MVV wrote:E.g. I have buttonbar button with Russian hint. If I have EN keyboard layout active when copying button via context menu, TC copies button code in wrong encoding (even when I paste text into Unicode application, text is wrong), but if I switch to RU all is right.

Does TC copy button code in ANSI? Or why such bug occurs?
2MVV
Isn't this issue fixed already? It seems it was fixed even before adding a support for pasting of a Unicode text to a button bar in TC 9.10.

If yes, maybe this topic should be moved to fixed bugs?
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Yes, it is fixed already, just rechecked - works ok.
Post Reply