+[8.5b2] Compare & Edit: Unicode problem

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

Moderators: Hacker, petermad, Stefan2, white

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

+[8.5b2] Compare & Edit: Unicode problem

Post by *MVV »

0. Maybe you will need non-US codepage to reproduce this bug (Russian in my case).
1. Open Notepad and type some non-English characters (from second half of your codepage; in my case some Russian letters).
2. Then switch keyboard layout to English (!) and copy typed text.
3. Try to paste text to Compare & Edit window: wrong text is inserted (in my case it is inserted as ??????????).
4. To ensure it is TC problem and not Notepad, open some other Unicode application, e.g. write.exe or Word, and insert text into it. Correct text is isnerted.

So, Compare & Edit always takes ANSI format from clipboard even if Unicode one is there also. But it should take Unicode one if available.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50861
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The problem is that notepad doesn't set the codepage, so when TC requests the ANSI clipboard, Windows makes the wrong conversion.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I know that Windows puts ANSI text to clipboard with codepage taken according to current keyboard layout.
But any Unicode application puts Unicode text to clipboard and Compare&Edit should use it first but it doesn't.

Please check, it seems that Compare&Edit clipboard reading function uses CF_TEXT format while it should use CF_UNICODETEXT format.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50861
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Compare uses Unicode clipboard only when editing Unicode or UTF-8 file.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

You can use it always, WideCharToMultiByte with codepage CP_ACP converts UTF-16 to ANSI.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50861
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Hmm, maybe better use the codepage set for the current font.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Since all ANSI files have CP_ACP encoding, I think it is better to use it for pasted data too.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50861
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Interestingly I was already using the Unicode clipboard in the 64-bit version. I will use it in the 32-bit version too.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Thanks, works fine in 8.50b3/4.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50861
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Great, thanks for checking it again!
Author of Total Commander
https://www.ghisler.com
Post Reply