I have a 3rd party application from which I need to copy texts and paste it into visual studio. However, when I copy the text like vysvedčenie and paste into Visual Studio text editor, I get vysvedèenie.
I bet it’s due to the other program putting non-unicode encoded text into clipboard. So I made a program to periodically check clipboard and convert the text into unicode like this:
var originalText = Clipboard.GetText(TextDataFormat.Text);
Clipboard.SetText(originalText, TextDataFormat.UnicodeText);
This works fine, but the problem is how do I determine I already have a unicode-encoded text in the clipboard so that I don’t try to convert it again?
I thought that Clipboard.ContainsText(TextDataFormat.UnicodeText) would work, but this always returned true.
Use
Clipboard.GetDataObject().Then you can call
GetFormats()on theIDataObjectreturned.