How to convert a Chinese registry value from within a US code page?

First of all, our Win32 MFC VC++ app is not written in Unicode as it should have been. Given that - it reads uninstall information from the windows Uninstall registry tree and writes it to a report. It writes out the displayname of the application.

Normally this is not a problem, but when it encounters a Chinese application name, it displays the name as question marks. I assume this is because the string is in Unicode in the registry, but our app is not Unicode so it can't represent the characters.

Unfortunately for the moment, converting this very large app to Unicode is not an option.

How can we (or can we at all?) convert these "????" strings to their actual Chinese characters?

We have the Chinese character support added via the control panel's Regional Settings, so we can see the Chinese chars correctly when we view them in RegEdit, etc., even though our current regional settings are for US. (changing the regional settings via the control panel to Chinese is not an option). It's just our app that returns the ????? chars.

We've tried explicitly calling RegQueryValueExW to read the value, but it still comes back to us as '????'.

Is it possible to read a unicode string from the registry from a non-unicode application?

Any help would be greatly appreciated!

Thanks!
LVL 1
rascalAsked:
Who is Participating?
 
rascalAuthor Commented:
Unfortunately the sMyString,su showed still as ????

Below is a note from a Microsoft contact on a newsgroup:

Hi,
I understand that you would like to know if you can have your non-Unicode
Win32 application display Chinese characters.
If I have misunderstood, please let me know.

From my research, it seems hard to resolve it by programming. I wrote a
Win32 console program and tried using setlocale(LC_ALL,".936") function,
however it had no effect.
This issue should be related to the display device which require your
changing reginonal settings so that it can support displaying Chinese
characters.
As a workaround, you may change the regional settings, however you need not
change the main regional settings but just change "Language for non-Unicode
programs" to "Chinese (PRC)" in Advanced tab. This modification requires
your rebooting your computer.

I will also consult the development team to see if they can give me some
suggestions on programmatically resolve this issue, however the process may
need a long time.
0
 
mahesh1402Commented:
>>We've tried explicitly calling RegQueryValueExW to read the value, but it still comes back to us as '????'.

How you are checking that string ?

>>We have the Chinese character support added via the control panel's Regional Settings,

Have you tried  by changing the Language for 'non-Unicode programs' in control panel ? by Opening the control panel,Select Regional and Language Options,Select the Advanced tab,Select the desired language in the drop down list ??

-MAHESH
0
 
mahesh1402Commented:
>>Is it possible to read a unicode string from the registry from a non-unicode application?

As said above For that, you need to set "Language for non-Unicode programs" to "Chinese (PRC)", this option can be found through Control Panel -> Regional and Language Options -> Advanced. Additionally, Windows may prompt you to install East-Asian support. You need your installation media to proceed.

-MAHESH
0
 
rascalAuthor Commented:
Changing to "Chinese PRC" is not an option since our program is run on several machines that are set to run in the US Language. These US machines have various Chinese programs installed on them, so they have the Chinese characters in the registry. So we were just wondering if it was possible to read the Chinese chars from the registry from an application that was not built with #define UNICODE defined for it.
0
 
DanRollinsCommented:
The data may be there, but it is just showing as ???? in the DevStudio U/I

You can view the binary elements of the string to verify that.

Is the data in a CString?  A byte buffer, or what?

In the Watch Window, try replacing
   sMyString
with
   sMyString,su

see:
     Character Formatting of Watch Variables
     http://msdn2.microsoft.com/en-us/library/aa934325.aspx

 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.