Loading...
 

Why do strings appear as ???

This article applies to VB6 applications using non western (e.g. Chinese, Japanese, Korean) characters.

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.
Image
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

More information
You can find more information on this subject in Micheal Kaplan's book, "Internationalization with Visual Basic".

The chapter entitled "VB-Is it ANSI or Unicode" is available online.
VB6 is, for the most part, a Unicode system. All strings in VB6 are Unicode strings.


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

UniToolBox
Based on the product description, the UniToolbox provides replacement for the VB6 built-in controls and the menu system designed to solve exactly this problem.

I have not tested this product.
As described above, this problem is not as bad as it seems, because it probably won't occur on the end user's system.


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

See also Changing Language for non-Unicode Programs on the Microsoft Global Development web site.

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

Image

  • Select Regional and Language Options

Image

  • Select the Advanced tab

Image

  • Select the desired language in the drop down list

Image

  • Click on OK to close the dialog
Note: If you have not already installed the fonts for this language on your system, you will need to have your original Windows XP CD, so that Windows can copy these fonts now.

Changing the Language for non-Unicode programs under Windows 2000

See also Changing Language for non-Unicode Programs on the Microsoft Global Development web site.
  • Open the control panel

Image

  • Select Regional Options

Image

  • Click on the button "Set default" at the bottom left of this dialog

Image

  • Select a language from the drop down list
  • Click on OK to close this dialog
  • Click on OK to close the regional options dialog
Note: If you have not already installed the fonts for this language on your system, you will need to have your original Windows XP CD, so that Windows can copy these fonts now.

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.
Image


Created by admin. Last Modification: Wednesday 16 of January, 2008 21:56:55 GMT by admin.