Discussion:
Chinese Windows difficulties
(too old to reply)
Tony Duff
2009-09-21 07:18:01 UTC
Permalink
I have wordprocessor that I develop and compile in English under English Vista.

I use the edit controls available in the Windows SDK for various dialogues.

I load text into the Window using SetWindowText and retrieve the text using
GetWindowText. (Both items are the single character ANSI versions, not the W
versions for double-byte.

The compiled program works perfectly well under English and other European
language Windows. However, there is a problem under Chinese Windows whenever
the character set into the control is over decimal 126. For example, I load
a single character decimal 204 into the control. When I retrieve it using
GetWindowsText under English Windows, I get back a string containing only the
single character decimal 204 terminated with a null character, as expected.
Under Chinese Windows, the exact same code results in a string beginning with
a ? question mark and followed by about 13 apparently random characters.

Can anyone explain why this would be and as a result what the fix would be?

Thanks,
Tony Duff



I've got an RTF import method in my wordprocessing program.

I'm trying to add the ability to read in files created in Chinese versions
of Windows. I have taken care of the Unicode aspect but I need to take care
of the older system that uses double characters and high codes with composite
fonts.

For instance, the RTF code contains

\dbch\'co\'ao

I understand this is a double byte character but it is not a unicode. So,
once I have obtained these two charactersOnce I incorporate these letters
into my program, what is the right way to display them so that the correct
Chinese letter displays? Do I send them to textout as a string of two
characters, one after the other just as I received them with the appropriate
font and character set selected? Or what?

Thanks for your help,
Tony Duff
Mihai N.
2009-09-21 08:23:45 UTC
Permalink
Post by Tony Duff
Can anyone explain why this would be and as a result what the fix would be?
Explantion:
When you run on a Chinese system with a non-Unicode application all text
is interpreted as being in the Chiense code page (cp936)

In that code page 204 decimal is the first half of a Chinese character.
The second half is missing (zero in your string), so what you have
there is a corrupted Chinese character (rendered as a question mark).

Fix:
Move to Unicode.
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Tony Duff
2009-09-24 10:31:02 UTC
Permalink
Post by Mihai N.
Post by Tony Duff
Can anyone explain why this would be and as a result what the fix would be?
When you run on a Chinese system with a non-Unicode application all text
is interpreted as being in the Chiense code page (cp936)
Move to Unicode.
Thanks for the explanation. I agree that moving to unicode is a good idea.
However, this is a very large job for us, one that will take some time. We
need a temporary fix for this for our customers right now. Is there a way
programmatically to change the default language of the single line edit
control? And, as a second question, is there a way to query at run-tine
whether the Windows is Chinese, Japanese, Korean Windows?

Thanks in advance,
Tony Duff
Mihai N.
2009-09-25 10:41:57 UTC
Permalink
Post by Tony Duff
We
need a temporary fix for this for our customers right now. Is there a way
programmatically to change the default language of the single line edit
control?
There is no temporary fix.
Things use Unicode, or the current system code page.
So you cannot show Chinese text on English system,
or Enghish with values above 127 on Chinese, etc.

There are some hacks, but nothing reliable or oficially supported.
Post by Tony Duff
And, as a second question, is there a way to query at run-tine
whether the Windows is Chinese, Japanese, Korean Windows?
GetACP => "Retrieves the current Windows ANSI code page identifier
for the operating system."
That is exactly the thing that affects what you see.
("ANSI code page" : MS lingo for current system code page)
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Tony Duff
2009-09-25 11:56:01 UTC
Permalink
Post by Mihai N.
There are some hacks, but nothing reliable or oficially supported.
OK, so give me a hack. I don't care whether it's officially supported or not.
Post by Mihai N.
Post by Tony Duff
And, as a second question, is there a way to query at run-tine
whether the Windows is Chinese, Japanese, Korean Windows?
GetACP => "Retrieves the current Windows ANSI code page identifier
for the operating system."
That is exactly the thing that affects what you see.
Yes, I get it. My question exactly is what I can do to change the ANSI code
page identifier for my program. Again, right now I don't care how much of a
hack it is.

Tony Duff
Mihai N.
2009-09-26 09:54:09 UTC
Permalink
Post by Tony Duff
My question exactly is what I can do to change the ANSI code
page identifier for my program.
You can't. That is why it is called "system code page"
It is system-wide, you don't change it for one application only.
If you change it, requires a reboot, and affects all applications.
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Kalle Olavi Niemitalo
2009-09-26 11:08:52 UTC
Permalink
Post by Tony Duff
Yes, I get it. My question exactly is what I can do to change the ANSI code
page identifier for my program. Again, right now I don't care how much of a
hack it is.
The Microsoft AppLocale Utility
http://www.microsoft.com/globaldev/tools/apploc.mspx

Continue reading on narkive:
Loading...