Why do strings appear as ???
The question that I am most often asked with regard to VB6 localization, is why texts sometimes appear as question marks, as in the following example.
This effect happens with all of the built-in VB controls (Labels, Text-Boxes, List-Boxes, etc.) and in VB6 menus.
Unicode and non-Unicode controls
All VB6 interfaces are based on the Component Object Model (COM) which only supports Unicode strings. This means that any string passed to a control is necessarily a Unicode string.
However, this does not mean that a control must use Unicode internally.
Internally, the VB6 Built-In controls and VB6 menus do not use Unicode
Most commercially available components and in fact most components from Microsoft (such as the Windows common controls) use Unicode internally, and therefore do not cause any problems.
However, the VB6 built-in controls and the VB6 menu system work internally with ANSI (or strictly speaking Multibyte) encoding, and this is the whole cause of the problem.
Multibyte characters and Codepages
Using ANSI or Multibyte character encoding does not mean, that controls and menus cannot display other character sets. The VB6 built-in controls and menus can, for example, display Chinese characters, but only using the correct Chinese codepage.
(You can find more information about codepages in Michael Kaplan's book.)
This means, that your end users might not even have this problem!
For example, if your development system uses an English version of Windows, then you may have a problem showing Chinese characters, because you are using the wrong codepage. However, a Chinese user will most likely have a Chinese version of Windows, which will use the correct codepage and therefore display Chinese characters correctly.
Fixing the problem for the User
I have not tested this product.
If this is not good enough, then it is a serious problem. You will probably have to avoid using the VB6 built-in controls entirely and use owner drawn menus. Again I would refer you to Michael Kaplan's book for more information. However, from today's standpoint, moving to VB.NET may well be a better option.
Fixing the problem for the Developer
Assuming you can live with this problem, you will nevertheless want to see the characters properly on your development system.
The good news is, that if you are using Windows 2000 or Windows XP, then this is possible. Under Windows 2000 and Windows XP, it is possible to change the codepage used for non-Unicode applications. The rest of this article describes how to do this.
AppLocale for Windows XP
Under Windows XP, there is an alternative solution, which is a utility called AppLocale.
This utility allows you to change the codepage for a single non-Unicode application, without affecting all applications in the system.
You can find more information on AppLocale and download the utility from the Microsoft Global Development web site.
Changing the Language for non-Unicode programs under Windows XP
The exact appearance on your system may differ from the screenshots shown below (since I do not use the default XP window style).
- Open the control panel
- Select Regional and Language Options
- Select the Advanced tab
- Select the desired language in the drop down list
- Click on OK to close the dialog
Changing the Language for non-Unicode programs under Windows 2000
- Open the control panel
- Select Regional Options
- Click on the button "Set default" at the bottom left of this dialog
- Select a language from the drop down list
- Click on OK to close this dialog
- Click on OK to close the regional options dialog
The End Result
The following screen shots show a VB6 application localized into Chinese (using the Multi-Language Add-In for VB6). As you can see, Chinese characters appear correctly in the menus.