Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

1 view
Skip to first unread message

Mark Findlay

unread,
Jul 24, 2007, 2:55:24 AM7/24/07
to
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!


David Webber

unread,
Jul 24, 2007, 4:57:54 AM7/24/07
to

"Mark Findlay" <mfin...@speakeasy.org> wrote in message
news:R_ednclhybk8Pzjb...@speakeasy.net...

>...


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

Using WCHAR (wchar_t) explicitly and calling the ...W() versions of API
functions should work if you do it consistently. (You also have to make
sure that when you look at it, you are using a font which has all the
relevant unicode characters.)

Do the Watch Windows in VS2005 display wchar_t strings including Chinese
characters? I believe they do - certainly I can see the musical flat
symbol which is somewhere on another planet in the unicode set. (I don't
know for sure, but I'll bet this doesn't work in Visual Studio 6.)

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

Because of the history of my application I am using a mixture of CHAR,
WCHAR and (as much as possible) TCHAR with the appropriate routines to
handle each. It now works when compiled with and without the UNICODE flag.
I have always used the standard registry functions with TCHAR but everything
else has worked fine and so I have no doubt that the registry functions will
work too if you do it consistently.

Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm

Norman Diamond

unread,
Jul 24, 2007, 8:16:46 PM7/24/07
to
As someone else pointed out, call the W versions of the registry APIs in
order to retrieve strings in Unicode.

When you call WideCharToMultiByte you can specify what code page to use.
You can convert them to Chinese ANSI strings. But if you display these in a
window that uses a US-English code page, the results will look like garbage.
If you don't use Unicode, you'll have to make sure that all parts of your
application are on the same code page.


"Mark Findlay" <mfin...@speakeasy.org> wrote in message
news:R_ednclhybk8Pzjb...@speakeasy.net...

Rolf Harbauer

unread,
Jul 25, 2007, 3:03:54 AM7/25/07
to
Hello Mark,

why not use 'IMultiLanguage' interface (comes with IE 4), with functions
'ConvertStringFromUnicode' and 'ConvertStringToUnicode'.
With this interface, you are independant from the current process local ...

Rolf


"Mark Findlay" <mfin...@speakeasy.org> schrieb im Newsbeitrag
news:R_ednclhybk8Pzjb...@speakeasy.net...

0 new messages