4
votes

Our app has a bug in the non-unicode version; if we copy some Russian characters to the clipboard(using SetClipboardData(CF_TEXT)), and then paste them into notepad, they don't get pasted as the Russian characters but as the code page 1252 equivalents (e.g. Э becomes Ý).

In trying to figure it out I made a little test app for pasting and it worked fine if I used GetClipboardData(CF_TEXT). if i use GetClipboardData(CF_UNICODETEXT) however, it has exactly the same issue as notepad.

So I assume that notepad is just using CF_UNICODETEXT on the paste. According to the MS documentation I've read, the clipboard is supposed to be able to convert CF_TEXT to CF_UNICODE text. In fact on the page:

http://msdn.microsoft.com/en-us/library/ms649013.aspx#_win32_Synthesized_Clipboard_Formats

it says "there is no advantage to placing the conversion format(s) on the clipboard."

If that is true then i must (I hope) be making a simple mistake that is easily corrected.

Can anyone help me out with a solution for this problem? Thanks

1

1 Answers

6
votes

You're probably missing the CF_LOCALE for Russian? CF_TEXT is interpreted using the system locale, unless specified otherwise. If your system locale charset is CP1252, but your app locale is CP1251, windows will mis-guess when it converts your 8 bits text to Unicode.