I noticed that if you copy-paste web browser content into Notepad (or any text editor), you get different results, depending on the browser used.
That is, if you try the开发者_Python百科 following:
- Ctrl-A (while inside IE, Firefox, Chrome, etc.)
- Ctrl-C
- Ctrl-V (inside Notepad)
You will see that the text content from Internet Explorer is different than the one from Firefox.
(I conducted this test on Windows XP and Windows 7)
Why is that?
Are web browsers free to use any algorithm they choose to convert HTML content to CF_TEXT?
If so, are there any "minimal rules" they must adhere to?
When you copy data from the browser, the browser is responsible for converting data into the various clipboard formats. Since all of these data conversions can be expensive, most browsers will defer the conversion until a call is made to retrieve the clipboard data. According to MSDN, this is accomplished by calling SetClipboardData with a NULL for the second parameter. When a later call is made to GetClipboardData, the browser receives a WM_RENDERFORMAT or WM_RENDERALLFORMATS message. It is at this point that the browser performs the conversion to text. There are no particular rules that the browser must follow when performing this conversion.
精彩评论