OS/2 codes: How to execute a child process in a specific code page

A code page is legacy and is being replaced with a unicode system. Unfortunately, however, OS/2 still use a code page. In addition, it supports maximum 2 code pages only at a time. They are called as primary code page and secondary code page, respectively. Of course, PM programs can more free from a code page, but they are also affected by a code page, so called process code page. In this ariticle, we will find how to control those code pages, especially for child process.

OS/2 provides several APIs for a code page. Out of them, our concern is DosSetProcessCp(). Its systanx is

#define INCL_DOSNLS
#include <os2.h>

ULONG     cp;    /*  A code page identifier. */
APIRET    ulrc;  /*  Return Code. */

ulrc = DosSetProcessCp(cp);

Reference: http://cyberkinetica.homeunix.net/os2tk45/cp1/1726_L2H_DosSetProcessCpSynta.html

DosSetProcessCp() changes the current process code page. And the important thing is the changed code page is inherited by a child process.

However, this does not work on Warp 4.5, Warp 4 + FixPak #13 and eComStation. Because they introduced a new feature. That is, [Language] tab in [Properties]. There, you can select a locale and a code page with which you start a program. The code page changed by DosSetProcessCp() is ignored by this setting.

Then, we cannot override this settings ? Yes, we can ! ^^

Warp 4.5 introduced WORKPLACE_PRIMARY_CP environmental variable with introducing [Language] tab. If it is set to 1, then child process are started in a primary code page. If it is set to 0, then chid process are started in a secondary code page. Both these ignore DosSetProcessCp(). Then, What should we do to respect DosSetProcessCp() ? Set it to ?. It means to start a child process in a current process.

As a result, if you want to start a child process in a code page which you want, do like the following.

  1. Check existence of WORKPLACE_PRIMARY_CP
  2. If exists, set it to ?, else ignore
  3. Change a code page with DosSetProcessCp()
  4. Start a child process 

As I said above, WORKPLACE_PRIMARY_CP ignores DosSetProcessCp(). Therefore, if you just set WORKPLACE_PRIMARY_CP to 1 or 0 without calling DosSetProcessCp(), a child process will be started in a primary code page or a secondary code page, respectively.

For example codes, see



댓글

이 블로그의 인기 게시물

토렌트: < 왕좌의 게임 > 시즌 1 ~ 시즌 8 완결편 마그넷

토렌트: NGC < 코스모스 > 우리말 더빙 전편(1편~13편) 마그넷

토렌트: < 스타워즈 > Ep.1 ~ Ep.6 마그넷