Unicode in RichEdit 2

From: Glen Perkins (Glen.Perkins@nativeguide.com)
Date: Fri Dec 03 1999 - 20:29:42 EST

Fellow Unicoders,

Would anyone here be willing & able to provide a simple "hello, world" that
demonstrated how to display Unicode in RichEdit 2 on (US or other Western)
Win98 using C/C++?

RichEdit 2 ships with every copy of Win98 (unless I'm mistaken) and, unlike
RichEdit 1, it claims the ability to display Unicode. It's also the first
version of RichEdit to support COM, and the two go hand in hand because
COM's strings (BSTR's) are always Unicode strings, regardless of which
version of Win32 you're using.

I've had no luck yet. A lot of people appear to have tried and failed. In
September, MS's VP of developer relations told me he'd find somebody
internally who could send me a "hello, world" demo app. The search is still
on. I've had several responses from developers within MS of the sort "maybe
you could try X", but apparently they've never tried "X" themselves. Every
month or so, I email this VP to inform him that I still don't have a working
"hello, world", and within hours I get several responses from developers
within MS offering code snippets that "might work" that don't even compile,
that use APIs that MSDN claims are "unsupported" on Win98, or messages
informing me that "somebody really ought to write a basic 'hello, world' to
demonstrate this -- that's a good idea, but I don't know how myself."

My goal for this "hello, world" app is to display the C/J/K word for "China"
( zhongguo/chuugoku/jung'gug : U+4e2d U+570b) in a RichEdit 2 control on
(any non-Asian) Win98 with any one of the East Asian language packs
installed. I'm not asking for complex scripts or bidi or even italics. Just
two simple CJK chars forming the word "China". (The complex script support
can come later with later versions of RichEdit, but I need simple scripts

I've tried using EM_STREAMIN, which works fine for "ANSI" (i.e. cp1252), but
behaves weirdly for Unicode. (And, yes, it really is RichEdit 2, because I
can autodetect URLs, and the correct Asian font is clearly being used.) The
results are a mess, and it's not simply "mojibake" (wchar stream out of sync
by one byte).

I'm thinking that COM might be a better approach, though. It's too
heavyweight for my taste, but COM strings (BSTR's) are always Unicode on
every version of Win32. It's becoming clearer to me that if I need to do
something on Win98 with Unicode, the way to phrase the question is "how do I
do it with COM?", not "how do I do it with Unicode?". MS support can seldom
answer a Unicode question, but they can often answer COM questions. My guess
is that the testers test COM directly, and Unicode only indirectly, if at
all. Also, a gazillion VB'ers use COM while only a handful of i18n crackpots
ever try using Unicode directly on Win9x via C++. I figure that it's
probably a lot safer to use COM for Unicode rather than trying to use the
Win32 APIs directly, but I'd gladly settle for either.

Would anyone here be able to provide such a "hello, world"? COM or Win32
API, my first choice would be for code that actually compiled and a
resulting app that really worked. ;-)


This archive was generated by hypermail 2.1.2 : Tue Jul 10 2001 - 17:20:56 EDT