Application & Data Migration Blog Posts | Mobilize.Net

Migrating VB6 with non-ASCII characters

Written by Will Vasquez | Oct 1, 2024 10:28:11 PM

As you may already know, the Visual Basic Upgrade Companion (VBUC) is the premier tool for converting legacy VB6 applications to .NET.

One of the many scenarios that VBUC supports is the migration of applications containing non-ASCII characters. This is crucial for applications with strings or comments in languages such as Japanese, Chinese, or Hebrew.

Working with encodings, code pages, and regional settings can be complex and often requires a refresher. Scott Hanselman provides an excellent explanation of these basic concepts here: https://www.hanselman.com/blog/computer-things-they-didnt-teach-you-in-school-2-code-pages-character-encoding-unicode-utf8-and-the-bom.

Originally, Visual Basic stored these characters in Unicode, displaying them correctly in the VB6 IDE.

The VBUC generates code files using UTF-8, considering the developer’s regional settings to accurately convert the original characters into their UTF-8 representation.

However, if these settings are not configured correctly, you might end up with garbled text in the migrated application.

So, for a source like this one: 

You might end up with this:

Or this:

The answer to this is to simply set the system locale to English during the conversion process, following these steps:

  1. Open Control Panel
  2. Click on Clock and Region settings
  3. Click on Region settings
  4. Click on Administrative tab
  5. Click on Change system locale button
  6. Change the Current system locale to English (United States)
  7. Click on OK button and restart the computer
  8. Upgrade the code using the VBUC
  9. Change the Current system locale to its default value (Japanese in this case) and restart the computer
  10. Open the generated solution

Now the generated code will be using UTF-8 and will work in any environment you move it to.

As usual, if you have any questions, feel free to reach out and book a session with us: https://www.mobilize.net/talk-to-an-engineer.