[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2007-07-23
5
Medium Priority
?
718 Views
Last Modified: 2013-11-20
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!
0
Comment
Question by:rascal
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 19554020
>>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
 
LVL 22

Expert Comment

by:mahesh1402
ID: 19554037
>>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
 
LVL 1

Author Comment

by:rascal
ID: 19556450
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 19560736
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
 
LVL 1

Accepted Solution

by:
rascal earned 0 total points
ID: 19561981
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question