Post Reply 
newRPL-Desktop past and copy
12-23-2020, 03:40 AM
Post: #9
RE: newRPL-Desktop past and copy
(12-22-2020 05:40 PM)Thomas Okken Wrote:  SetClipboardData(CF_UNICODETEXT, ...) should be compatible with everything, it's one of the standard formats in Windows. This uses UTF-16. I didn't know you could even use UTF-8, but it's certainly not guaranteed to be supported by everything. In files, yes, but on the clipboard, no.

It's not a big problem since the conversion is easy with MultiByteToWideChar() and WideCharToMultiByte()...

Not so simple. I use Qt because the same code is newRPL Desktop for Windows, Linux, MacOS and even Android. I don't want direct Windows API calls, it's all abstracted in the library and outside my control.
NewRPL uses multi format data in the clipboard. Right now it uses 3 separate formats simultaneously: text/plain with utf8 charset, HTML and binary. Plain text is what Linux and MacOS like better. Windows didn't accept this, for windows plain text was just ASCII, all Unicode characters were messed up.
But then Windows had Rich Text (which went obsolete long ago) and HTML, so newRPL uses HTML (which is utf8 encoded by default). Windows preferred the HTML when available so it worked well.
The third format is a binary object to avoid any loss of information when you copy/ paste between newRPL instances.

This worked fine even on Windows 10 until not sure when (must've been one of the last big updates). From doing some additional testing, it seems that now Windows dropped support for pasting HTML in most of its controls, and is not accepting the plain text with UTF8 either (plain text without indicating encoding is accepted, or perhaps it's converted to UTF-16 by Qt internally). This may be a security thing perhaps, who knows. Old applications like the HP Prime Connectivity kit which have a "Win7" styling work well, including Unicode characters because they paste the HTML version of the data in the clipboard.

Funny enough, now the plain text in Windows 10 is no longer ASCII, it's fully Unicode. I just tested it and all characters were pasted as they should on all Win10 controls and in Notepad.

So I guess I'll just eliminate the HTML, and leave the text as plain text, I still need more testing to make sure it doesn't break Linux or Android. Problem is, this will likely break support for Windows 7... I have a lot of testing to do to make sure I get this right, perhaps adding a 4th format...
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
newRPL-Desktop past and copy - Klaus - 12-21-2020, 03:50 PM
RE: newRPL-Desktop past and copy - _nmr_ - 12-22-2020, 01:18 PM
RE: newRPL-Desktop past and copy - Claudio L. - 12-23-2020 03:40 AM
RE: newRPL-Desktop past and copy - Klaus - 01-23-2021, 08:38 AM



User(s) browsing this thread: 1 Guest(s)