by Michael S. Kaplan, published on 2008/04/23 10:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2008/04/23/8415969.aspx
Content of Michael Kaplan's personal blog not approved by Microsoft (see disclaimer)!
Regular readers should keep in mind that all I said in The End? still applies; the allusion to the X-Files continues for people who understand such references....
Over in the Suggestion Box, Bruce Rusk asked:
To keep a long story long: I have an application that I need to use--it's a Chinese dictionary that I use daily and would be seriously bummed to live without. It's a badly-designed Foxpro application, targeted to Traditional Chinese Windows (Big-5), and I run it in Windows XP with AppLocale.
It's finicky. It doesn't display quite properly, but well enough to be used. The main issue is with input: there are two ways that I've found to input characters to search:
(1) via the traditional Chinese IME
(2) by pasting ... but only from Notepad. Pasting from any other application (Word, a browser, everything else I've tried) results in question marks in place of the characters. Being able to paste is essential to help look things up from texts.
So my question is: will this rickety train continue to plod along after a Vista upgrade? Is there a way to tell beforehand whether Vista's IME will work and Vista Notepad will have the particular breed of whatever it is (braindeadness?) that makes its clipboard text paste properly? Or is there another way to massage the clipboard into the form this app seems to need?
Thanks!
The rickety train should keep muddling along, especially with either the use of AppLocale (though be sure to read the blog I wrote entitled The version of App Locale that runs on Vista? so you know how to get AppLocale on Vista!), or by changing the default system locale to a Traditional Chinese locale -- either way, this non-Unicode application will process the text.
And now we get to the problem, which is that the the dictionary application, which does not know to accept Unicode, is asking for CF_TEXT rather than CF_UNICODETEXT. Many more intelligent applications will register multiple clipboard formats as being available and when your application asks for CF_TEXT, Word (which assumes it knows the exact code page of the system and which registers the formats it accept so it can copy later on demand) is able to give that.
But then silly old Notepad just offers up CF_UNICODETEXT (it is actually even simpler than that but this is close enough for now, maybe I'll get into more later) and lets the system take care of the conversion by creating the text synthetically -- doing its own conversion to CF_TEXT. And since your Dictionary application running under AppLocale assumes the CP_ACP (default system code page) is 950, aka Traditional Chinese. The OS does the conversion and everything is done.
Word and IE and others are skunked by their own cleverness; in providing "better" functionality and not using the default OS clipboard synthetic behavior, these applications do worse!
There is actually no documented way to find out (when IsClipboardFormatAvailable(CF_TEXT) returns TRUE) which type of TRUE it means:
Now the reason that #1 and #2 can be different is left as either an exercise for the student or for some future blog for me to write some day (and yes it is on my list too, with lots of the information I learned from the MSLU days, including how to use CF_LOCALE as well!).
Notepad (or rather the underlying control within it) only knows to send CF_UNICODETEXT, which can work anywhere via #1 when it is requested or #2 when one of the other formats is.
But in the end all hope is not lost and you have two easy workarounds that requires no changes to applications and no external code to be written:
The former will simply work everywhere, and the latter will work between your Dictionary application and any application you set up to work with it....
This blog brought to you by អ (U+17a2, aka KHMER LETTER QA)
Bruce Rusk on 23 Apr 2008 6:55 PM:
Thanks for the quick (and, as always, entertaining) answer, Michael. I'm glad that I'll be able to keep the program going in the future.
Yuhong Bao on 30 Jul 2010 1:17 PM:
Raymond Chen mentioned it: