设置为 CF_TEXT 的剪贴板数据无法作为 CF_UNICODETEXT 正确检索
我们的应用程序在非 unicode 版本中存在错误;如果我们将一些俄语字符复制到剪贴板(使用 SetClipboardData(CF_TEXT)),然后将它们粘贴到记事本中,它们不会粘贴为俄语字符,而是粘贴为代码页 1252 等效项(例如 Э 变为 Ý)。
为了弄清楚这一点,我制作了一个用于粘贴的小测试应用程序,如果我使用 GetClipboardData(CF_TEXT),它工作得很好。但是,如果我使用 GetClipboardData(CF_UNICODETEXT),它的问题与记事本完全相同。
所以我假设记事本只是在粘贴上使用CF_UNICODETEXT。根据我读过的MS文档,剪贴板应该能够将CF_TEXT转换为CF_UNICODE文本。事实上在页面上:
http://msdn.microsoft.com/en -us/library/ms649013.aspx#_win32_Synthesized_Clipboard_Formats
它说“没有任何优势将转换格式放在剪贴板上。”
如果这是真的,那么我一定(我希望)犯了一个很容易纠正的简单错误。
谁能帮我解决这个问题? 谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能缺少俄语的
CF_LOCALE
?除非另有说明,CF_TEXT
使用系统区域设置进行解释。如果您的系统区域设置字符集是 CP1252,但您的应用程序区域设置是 CP1251,则 Windows 在将 8 位文本转换为 Unicode 时会误判。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.