Please enable JavaScript to view this site.

Navigation: Publishing > Publishing Your Projects

CHM in Asian Languages

Scroll Prev Top Next More

The Microsoft HTML Help / CHM help system is very old. It hasn't been updated significantly since it was originally released with Windows 98. In addition to other restrictions, this means that it doesn't support modern Unicode text encoding. It encodes Asian languages like Chinese, Japanese, Korean and Thai using the old "double-byte" system.

CHM needs Windows configuration to publish non-Latin languages

Double-byte encoding works fine, but only with additional support from Windows. You need to have the "system locale" of your Windows system set to the same language as that of the project you are publishing to CHM. If you don't, the entries in the table of contents will only display random characters for many letters and the search won't work.

The problem with multiple output languages

This is just about acceptable if you are only publishing a single CHM to a single Asian or other non-Latin language, even though it is annoying to have to restart Windows to change the locale setting. It becomes a real problem if you have different versions of your projects in different languages. The need to restart Windows for each language makes it impossible to build all your different versions in a single, efficient batch process.

It used to be possible to use Microsoft's "AppLocale" system to solve this problem, because it could change the locale on the fly during a batch process. However, this no longer works. It was only designed for Windows XP and Server 2003, and Microsoft terminated support for it in 2016.

The solution: Windows user accounts for each language

There is a way around the problem: If you set up multiple Windows user accounts, each account can have a different system locale. Also, in a batch file you can execute applications as a different user by using the runas directive. So if you set up a Windows account with the corresponding locale for each language you are publishing to, you can then publish multiple non-Latin CHMs correctly from any other account by using runas in your batch file to execute the publishing operations under the user account with the correct locale.

Step 1: Set up multiple locale accounts for CHM publishing

You need to set up separate Windows user accounts for each non-Latin language you are going to use for CHM output, and set the system locale for each account to the corresponding non-Latin language. We are going to use Chinese as an example. All these accounts need to be on the computer where the publishing is going to be performed, of course.

1.Create a new Windows user account with a descriptive user name. Let's say this account is going to be cn_user.

2.Include a password for the account.

3.Log into the new account and configure the system locale to the Chinese variant you will be using for this documentation. In Windows 10 this is accessed in Settings > Time & Language > Region > Additional date, time & regional settings. Then select Region in the new dialog that opens and you will find the locale setting in the Administrative tab. Alternatively, you can open the Control Panel directly and select the Region option.

4.Log out and log back in to your regular account. Then repeat steps 1-3 for each language you want to use.

Step 2: Execute the batch publish operation via runas

Important: If you are not yet familiar with command line and batch publishing please first study the Command Line Publishing chapter.

You are going to need to enter the account password manually the first time you do this, so you start by executing a single command line for each language. After that you can combine the commands for all operations in a single batch file.

You just need to prefix the normal command line with the runas directive and its two essential parameters, like this:

runas /savecred /user:cn_user "<path>helpman.exe <path>project.hmxz /chm=<path>project.chm"

Runas switches:

The /savecred switch is needed to save the password so that it will be available for later batches. (There is no way to include the password in the command line.) The /user: switch specifies the user account name.

Essential quote characters and escaping

The entire Help+Manual command sequence must be enclosed in double quotes (highlighted above). If your paths or other components require quotes because they include spaces you must escape those quotes with a backslash, like this:

runas /savecred /user:cn_user "helpman.exe \"my project.hmxz\" /chm=\"my project.chm\""

Run once to save the password

Run each command line once on its own. The console will open and prompt you to enter the password, which you must do blind, without seeing the password text or placeholder characters. The /savecred switch will save the credentials so that you don't need to enter the password manually next time.

Repeat this for each language, executing the single command line on its own and entering the password.

Step 3: Combine your command lines to a single batch

Once you have published each CHM once as described above to enter all the passwords you can build a single batch file for all your CHM versions in all languages. Just enter all the command lines in a single .cmd or .bat file, with each command line on a separate line in the file. Then you can execute the batch file from your regular Windows account and each one will be compiled with the correct locale without you having to change the locale on your computer or restart Windows.