Jump to content

DosQueryCp

From EDM2
Revision as of 04:24, 16 June 2016 by Martini (talk | contribs) (Created page with "==Description== Allows a process to query its current process code page and the prepared system code pages. ==Syntax== <PRE> #define INCL_DOSNLS #include <os2.h> ULONG c...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Allows a process to query its current process code page and the prepared system code pages.

Syntax

#define INCL_DOSNLS
#include <os2.h>

ULONG     cb;    /*  The length, in bytes, of arCP. */
PULONG    arCP;  /*  The returned data list. */
PULONG    pcCP;
APIRET    ulrc;  /*  Return Code. */

ulrc = DosQueryCp(cb, arCP, pcCP);

Parameters

cb (ULONG) - input
The length, in bytes, of arCP.
arCP (PULONG) - output
The returned data list.

The first ULONG is the current code page identifier of the calling process.

If one or two code pages have been prepared for the system, then the second ULONG is the first prepared code page, and the third ULONG is the second prepared code page.

If the data length is less than the number of bytes needed to return all of the prepared system code pages, then the returned list is truncated.

The code page identifiers have the values described in the following list:

437        United States 
850        Multilingual 
852        Latin 2 (Czechoslovakia, Hungary, Poland, Yugoslavia) 
857        Turkish 
860        Portuguese 
861        Iceland 
863        Canadian French 
865        Nordic 
932        Japan 
934        Korea 
936        People's Republic of China 
938        Taiwan 
942        Japan SAA 
944        Korea SAA 
946        People's Republic of China SAA 
948        Taiwan SAA 

Note: Code pages 932, 934, 936, 938, 942, 944, 946, and 948 are supported only with the Asian version of the operating system on Asian hardware.

pcCP (PULONG) - output
The length, in bytes, of the returned data.

Return Code

ulrc (APIRET) - returns

DosQueryCp returns one of the following values:

  • 0 NO_ERROR
  • 473 ERROR_CPLIST_TOO_SMALL
  • 474 ERROR_CP_NOT_MOVED

Remarks

DosQueryCp allows a process to query its current process code page and the prepared system code pages.

The process code page identifier previously set by DosSetProcessCp or inherited by the process is returned to the caller. An input list size of two bytes returns only the current process code page identifier. If no code pages have been prepared with the CODEPAGE command, a length of two and a current code page identifier value of zero are returned.

Note: If no CODEPAGE= statement exists in CONFIG.SYS, the operating system uses the first codepage that it finds in the COUNTRY.SYS file for that country.

The system code page identifiers are returned to the caller in the same order as they appear in the CODEPAGE command. The code page identifiers are returned in the following order:

  • The current code page of the process (one of the system code pages).
  • The primary (default) system code page.
  • The secondary system code page, if specified.

Example Code

This example gets the current code page and up to three other prepared code pages.

#define INCL_DOSNLS     /* National Language Support values */
#define INCL_DOSERRORS  /* DOS error values                 */
#include <os2.h>
#include <stdio.h>

int main(VOID) {
   ULONG  aulCpList[8]  = {0},                /* Code page list        */
          ulBufSize     = 8 * sizeof(ULONG),  /* Size of output list   */
          ulListSize    = 0,                  /* Size of list returned */
          indx          = 0;                  /* Loop index            */
   APIRET rc            = NO_ERROR;           /* Return code           */

   rc = DosQueryCp(ulBufSize,      /* Length of output code page list  */
                   aulCpList,      /* List of code pages               */
                   &ulListSize);   /* Length of list returned          */

   if (rc != NO_ERROR) {
      printf("DosQueryCp error: return code = %u\n",rc);
      return 1;
   } else {
      for (indx=0; indx < ulListSize/sizeof(ULONG); indx++)
         printf ("aulCpList[%u] = %u\n", indx, aulCpList[indx]);
   }

   return NO_ERROR;
}


Related Functions