Ask HN: How does copy/paste work on Windows?

4 points by taubek ↗ HN
Can I somehow see the exact content of clipboard in Windows? What puzzles me if I copy code from VSC or text from Word if I paste it into notepad I get text only.

But if I paste it to some HTML editor/component/blog I get the formatting.

How is this formatting stored in clipboard?

6 comments

[ 18.1 ms ] story [ 36.8 ms ] thread
What is stored in the clipboard depends essentially from the source it is copied from, and what is pasted to another program depends on what the target program is prepared to receive.

In the case of text, very often what is copied is plain text + formatted text like HTML or RTF (i.e. there are two - or more - "items" loaded to the clipboard) and when you paste, what is pasted is the default (or the only) kind of text that the program accepts (notepad accepts only plain text, other programs might allow you to choose between paste or paste text only).

Check:

https://freeclipboardviewer.com/windowsclipboard/

Try:

https://www.nirsoft.net/utils/inside_clipboard.html

Yes, this makes sense. Essentially wheb6 different formats are taken into consideration, eg. images, embedded spreadsheets, etc.
When you copy something, application can put data in multiple formats on clipboard. When you paste, application may or may not recognize some of those formats and will choose which one (if any) to use. In your example MS Word will store at least two formats. One is plain text and one is formatted. Which one is used depends on destination application (where you paste).

Others already recommended software that will let you see what's currently on the clipboard. In the past, Windows had application for that.

I didn't know that clipboard can contain multiple formats. Yes, I think that I remember that software. It was called Clipboard Viewer.