I'm working on a large, complex application that still uses mbcs. We were asked to add Russian language support. We made the necessary changes, and on our test machines, set to Russian locale, most of the strings show up as proper Russian. However, there are several places in the UI where the strings show up as "garbage" text. We've verified the strings displayed are coming from the resources, so it is not an access issue.
I'm focusing on one issue for now, where we display a property sheet with several tabs and all but two of the tabs show proper Russian. One observation is that for the tabs that display proper Russian, the resources live in the main .exe. The two tabs that do not display Russian, their resources live in an MFC extension dll. (This may be a coincidence, but I mention it anyway.)
The top of the .rc file for the problem tabs specify codepage 1251 (Cyrillic)
LANGUAGE LANG_RUSSIAN, SUBLANG_RUSSIAN_RUSSIA
#pragma code_page(1251)
The dialog itself (DIALOGEX) specifies "MS Shell Dlg" for the font, and the font statement specifies "DEFAULT_CHARSET" (int value 1) like this:
IDD_AZ_ANALYSISPAGE DIALOGEX 0, 0, 421, 366 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Анализ" FONT 8, "MS Shell Dlg", 0, 0, 1
Here is the resulting dialog. (Sorry, I am unable to post images or URLs for some reason, so you'll have to copy the url to your browser)
https://dl.dropboxusercontent.com/u/17010956/SettingsDlg.jpg
I'd like to point out a few things about this dialog.
1. Some of the property sheet elements show Russian (Cyrillic) characters. They were loaded explicitly via a LoadString() call and set on the UI in the OnInitDialog() call.
2. Only two of the tabs do not show Russian characters.
3. The dialog resources for the two tabs that do not show Russian live in a MFC extension dll. The tabs that show Russian have their resources in the main executable.
As a first thought from this, it seems the problem is related to the resources living in a MFC extension dll. I'm aware of the AFX_MANAGE_STATE macro and this is not the cause of the problem. The app can *find* and *load* the resources - it is just not displaying them properly.
As part of diagnosing this problem, I added code to the property sheet's "OnInitDialog()" method to get the code page and character set using "GetACP()", "CFont::GetLogFont()" and "GetCPInfoEx()" to get the thread's code page.
Everything was correct. The charset was RUSSIAN_CHARSET (204) and the code page was 1251 for both the OS and the current thread.
Another developer on the team has found a different property sheet dialog where some of the controls in a single property sheet display Russian and other display the "garbage" text. He found that if he simply moved some of the lines from the bottom of the dialog resource template to the top, it would affect which controls were affected by this problem.
Any MFC localization experts out there have any idea what might be going on? Or possibly some diagnostic things we can try?
Thanks,
Terry Henning
Senior Software Engineer