Jump to content

DosQueryCp: Difference between revisions

From EDM2
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..."
 
Ak120 (talk | contribs)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Description==
Allows a process to query its current process code page and the prepared system code pages.
Allows a process to query its current process code page and the prepared system code pages.


==Syntax==
==Syntax==
<PRE>
  DosQueryCp(cb, arCP, pcCP)
#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);


</PRE>
==Parameters==
==Parameters==
; cb (ULONG) - input : The length, in bytes, of arCP.  
;cb (ULONG) - input : The length, in bytes, of arCP.
 
;arCP (PULONG) - output : The returned data list.
; arCP (PULONG) - output : The returned data list.
:The first ULONG is the current code page identifier of the calling process.
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.
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.
:The code page identifiers have the values described in the following [[Code pages|list]].
 
;pcCP (PULONG) - output : The length, in bytes, of the returned data.
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==
==Return Code==
ulrc (APIRET) - returns
;ulrc (APIRET) - returns:DosQueryCp returns one of the following values:
 
* 0 NO_ERROR
DosQueryCp returns one of the following values:
* 473 ERROR_CPLIST_TOO_SMALL
 
* 474 ERROR_CP_NOT_MOVED
* 0     NO_ERROR
* 473       ERROR_CPLIST_TOO_SMALL  
* 474       ERROR_CP_NOT_MOVED  


==Remarks==
==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.


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.
 
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 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 current code page of the process (one of the system code pages).
* The primary (default) system code page.
* The primary (default) system code page.
Line 72: Line 31:
==Example Code==
==Example Code==
This example gets the current code page and up to three other prepared code pages.
This example gets the current code page and up to three other prepared code pages.
<PRE>
<PRE>
#define INCL_DOSNLS    /* National Language Support values */
#define INCL_DOSNLS    /* National Language Support values */
Line 100: Line 58:
   return NO_ERROR;
   return NO_ERROR;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosMapCase|DosMapCase]]
*[[DosMapCase]]
* [[OS2 API:CPI:DosQueryCollate|DosQueryCollate]]
*[[DosQueryCollate]]
* [[OS2 API:CPI:DosQueryCtryInfo|DosQueryCtryInfo]]
*[[DosQueryCtryInfo]]
* [[OS2 API:CPI:DosQueryDBCSEnv|DosQueryDBCSEnv]]
*[[DosQueryDBCSEnv]]
* [[OS2 API:CPI:DosSetProcessCp|DosSetProcessCp]]
*[[DosSetProcessCp]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 17:41, 12 October 2018

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

Syntax

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

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