Let's say you're on Windows 11 (version 24H2) and using Chrome (version 132). Now, let's say you have a web page open in Chrome and you copy (using Ctrl+C) the following character to the clipboard:
Ϟ
This is character code 990
(U+03DE Greek Letter Koppa), and in UTF-8 it is represented by the byte sequence CF 9E
.
What gets stored in the clipboard? The character code or byte sequence based on the encoding of the web page?
I have a hunch it's the character code, since that would make whatever you paste it into be encoding-agnostic (as long as the destination uses Unicode), but I wanted to ask StackOverflow to be sure.
Let's say you're on Windows 11 (version 24H2) and using Chrome (version 132). Now, let's say you have a web page open in Chrome and you copy (using Ctrl+C) the following character to the clipboard:
Ϟ
This is character code 990
(U+03DE Greek Letter Koppa), and in UTF-8 it is represented by the byte sequence CF 9E
.
What gets stored in the clipboard? The character code or byte sequence based on the encoding of the web page?
I have a hunch it's the character code, since that would make whatever you paste it into be encoding-agnostic (as long as the destination uses Unicode), but I wanted to ask StackOverflow to be sure.
Text can be stored on the Windows clipboard in many different formats, such as standard formats like CF_TEXT
+ CF_LOCALE
for ANSI text, or CF_UNICODETEXT
for Unicode text, etc. As well as custom formats, such as CF_HTML
, etc.
Apps are encouraged to store as many different formats as is feasible for their purpose, but especially Unicode for text. Any app that then pastes from the clipboard can look at what format(s) are available and decide which one(s) it wants to use. If HTML makes the most sense, it can use that. If Unicode makes the most sense, it can use that instead. And so on.
There are tools/APIs available that let you view what is actually on the clipboard.
For example, when I copy the Ϟ
character using Chrome 132, my clipboard gets these formats:
But, when I copy the same character using FireFox 134, my clipboard gets these formats:
So, to answer your question:
What gets stored in the clipboard? The character code or byte sequence based on the encoding of the web page?
What gets stored is: