-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description
After migrating an application to .NET 10, Clipboard.GetText() sometimes returns corrupted text or an empty string when reading Unicode (e.g., Japanese) content from the Windows clipboard. This behavior did not occur prior to .NET 10.
Example of corrupted output:
Expected:
「うわ、ほんとだ……あれ、どれくらいの高さなんだろ」
Actual:
????????・????????????????
or:
"" (Length = 0)
The issue appears intermittently and is difficult to reproduce deterministically, but becomes noticeable under frequent clipboard updates. Note that using Clipboard.ContainsText(TextDataFormat.UnicodeText) and Clipboard.GetText(TextDataFormat.UnicodeText) has the exact same problem.
Reproduction Steps
- Create a WPF application targeting .NET 10.
- Monitor clipboard changes using WM_CLIPBOARDUPDATE.
- On clipboard updates, call Clipboard.GetText() to retrieve text contents.
- Frequently copy Unicode text to Clipboard
Minimal example:
if (Clipboard.ContainsText()) // You can also use Clipboard.ContainsText(TextDataFormat.UnicodeText)
{
// Occasionally returns empty string or mojibake
string text = Clipboard.GetText(); // Clipboard.GetText(TextDataFormat.UnicodeText)
}
Intermittently, the returned string is either empty (this is more common) or contains corrupted characters instead of the original Unicode text (this is rarer).
Expected behavior
Expected behavior
Clipboard.GetText() should consistently return the correct Unicode text as placed on the clipboard, or throw a managed exception if the clipboard data is temporarily unavailable.
It should never silently return corrupted text or an empty string when valid Unicode text exists.
Actual behavior
Clipboard.GetText() intermittently returns:
- An empty string (Length == 0)
- Or a string containing mojibake (e.g., ?, ・), or
No exception is thrown in these cases.
Regression?
Yes.
Yes. This code path worked reliably in previous .NET versions. I never had a problem with .NET 5, .NET 6, .NET 7, .NET 8, .NET 9.
Known Workarounds
No response
Impact
No response
Configuration
No response
Other information
No response