From: Mihai N. on

> The problem is that it does not work on Win7 English edition with Hong
> Kong language pack.

Must be Unicode for that.


> It also works on both of those when built with VS6.

Sorry, I don't believe that.


> The fundamental question is: what is different between the native Hong
> Kong Win7 and Win7 with HK language pack systems?

Language pack has nothing to do with it.
What matters is the system locale, which determines the system code page.
See here: http://www.mihai-nita.net/article.php?artID=20050611a
Set the system locale (or "Language for non-Unicode Programs") to
Chinese Hong Kong, reboot and it will work.

The other thing that might matter is on what system are you building the
thing (not the compiler version).

If the resources are encoded in big-5 (no UTF-8, the resource compiler
does not support utf-8) then you have to compile them on a Traditional
Chinese system, or have the proper #pragma code_pag

So, to recap:
- How do you compile the resources
- The application is Unicode or not
- If not, then the system code page


As Ivo already explained, ?? means that characters were converted to a code
page that cannot represent them.
That can be when you compile the resources (case 1) or at runtime
(because the app is not Unicode and the system code page is not big-5)


--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

From: David on
On Feb 5, 5:20 am, "Mihai N." <nmihai_year_2...(a)yahoo.com> wrote:
> > The problem is that it does not work on Win7 English edition with Hong
> > Kong language pack.
>
> Must be Unicode for that.
Not true. The resources are built with 8-bit ANSI code-page specific
characters. I have solved the problem and gotten this to work
properly.
>
> > It also works on both of those when built with VS6.
>
> Sorry, I don't believe that.
>
Why don't you believe that? Why would you think I would lie about how
the program works - would doing so help me get a valid answer?
> > The fundamental question is: what is different between the native Hong
> > Kong Win7 and Win7 with HK language pack systems?
>
> Language pack has nothing to do with it.
> What matters is the system locale, which determines the system code page.
> See here:http://www.mihai-nita.net/article.php?artID=20050611a
> Set the system locale (or "Language for non-Unicode Programs") to
> Chinese Hong Kong, reboot and it will work.
>
> The other thing that might matter is on what system are you building the
> thing (not the compiler version).
>
> If the resources are encoded in big-5 (no UTF-8, the resource compiler
> does not support utf-8) then you have to compile them on a Traditional
> Chinese system, or have the proper #pragma code_pag
>
> So, to recap:
>  - How do you compile the resources
>  - The application is Unicode or not
>  -   If not, then the system code page
>
> As Ivo already explained, ?? means that characters were converted to a code
> page that cannot represent them.
> That can be when you compile the resources (case 1) or at runtime
> (because the app is not Unicode and the system code page is not big-5)
>
> --
> Mihai Nita [Microsoft MVP, Visual C++]http://www.mihai-nita.net
> ------------------------------------------
> Replace _year_ with _ to get the real email

To sum up the solution:
1) The difference between the native Hong Kong Win7 system and an
English system with HK language pack appears to be that the locale
used for non-Unicode programs on the latter system is the English-
language locale, while the HK-native version of course used the HK
locale. Hence, the English-language version doesn't use the 8-bit
characters against the correct code page (950) and doesn't have the
correct characters.
2) VS6 apparently apparently defaults to the USER's default locale
(and code page) as specified in the .rc file while VS2008 doesn't do
so.
3) The solution is to add a call to
SetThreadLocale(LOCALE_USER_DEFAULT) to the program. Then all works
properly.

Thanks to all who attempted to understand and solve this problem.
From: Mihai N. on

> 1) The difference between the native Hong Kong Win7 system and an
> English system with HK language pack appears to be that the locale
> used for non-Unicode programs on the latter system is the English-
> language locale, while the HK-native version of course used the HK
> locale. Hence, the English-language version doesn't use the 8-bit
> characters against the correct code page (950) and doesn't have the
> correct characters.

That's what I have explained.


> 2) VS6 apparently apparently defaults to the USER's default locale
> (and code page) as specified in the .rc file while VS2008 doesn't do
> so.

The user's default locale has nothing to do with this.
(that locale is only used to format dates/times/numeber/etc.)


> 3) The solution is to add a call to
> SetThreadLocale(LOCALE_USER_DEFAULT) to the program. Then all works
> properly.

That is not a solution. You will have other problems later on, you will see.
And again, LOCALE_USER_DEFAULT is the locale used for formatting,
has nothing to do with the UI locale, or code pages.


You have to set the Locale for non-Unicode programs to Traditional
Chinese in the English system. That is the relevant difference between
the real HK system and the English one.
And has nothing to do with Visual Studio (although it might be something
deep in MFC, if your application is MFC).


--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

From: Liviu on
"David" <dgintz(a)gmail.com> wrote...
>
>>> The problem is that it does not work on Win7 English edition
>>> with Hong Kong language pack.
> [...]
> To sum up the solution:
> 1) The difference between the native Hong Kong Win7 system and an
> English system with HK language pack appears to be that the locale
> used for non-Unicode programs on the latter system is the English-
> language locale, while the HK-native version of course used the HK
> locale. Hence, the English-language version doesn't use the 8-bit
> characters against the correct code page (950) and doesn't have the
> correct characters.
> 2) VS6 apparently apparently defaults to the USER's default locale
> (and code page) as specified in the .rc file while VS2008 doesn't do
> so.
> 3) The solution is to add a call to
> SetThreadLocale(LOCALE_USER_DEFAULT) to the program.
> Then all works properly.

If the above did indeed fix the problem, then you may have been bit
by http://msdn.microsoft.com/en-us/library/w1sc4t4k.aspx

"In versions of ATL up to and including ATL 3.0 in Visual C++ 6.0,
string conversions using the macros in atlconv.h were always performed
using the ANSI code page of the system (CP_ACP).
Starting with ATL 7.0 in Visual C++ .NET, string conversions are
performed using the default ANSI code page of the current thread"

(and the same applies to _wcstombsz, _mbstowcsz).

However, in that case, there must be more to your code than the
(over)simplified LoadString + SetWindowText you quoted earlier.

Liviu


From: Mihai N. on

>> Must be Unicode for that.
> Not true. The resources are built with 8-bit ANSI code-page specific
> characters. I have solved the problem and gotten this to work
> properly.

The .rc files get compiled to .res, and the .res files are always
Unicode, it does not matter if the .rc files are Unicode or not.
The code page uset to convert to Unicode is specified by
#pragma code_page or the /c switch in the resource compiler.
(the pragma takes priority)

At runtime the Unicode resources get loaded and used as is
if the application is Unicode, or converted to the ANSI code
page for non-Unicode applications.
Even you the resource loading starts using the thread locale
instead of the system locale, you will get big-5 strings in
an ANSI application running on a system with 1252 system code
page. So using the big-5 strings will lead to bugs down the line.
Loading them from resources is only half of the problem.
So you will see other bugs down the line.


The only way to safely run a Traditional Chinese application is
to set the system code page to 950 (by setting the language
for non-Unicode applications) or by making your application
Unicode.

Any other "solution" is unsupported, and will give you all
kind of problems.


--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email