Jump to content

DosQueryDBCSEnv: Difference between revisions

From EDM2
Created page with "==Description== Obtains a DBCS (double-byte character set) environmental vector that resides in the country file. ==Syntax== <PRE> #define INCL_DOSNLS #include <os2.h> ULONG..."
 
Ak120 (talk | contribs)
mNo edit summary
Line 7: Line 7:
#include <os2.h>
#include <os2.h>


ULONG           cb;    /* The length, in bytes, of the data area (pBuf) provided by the caller. */
ULONG       cb;    /* The length, in bytes, of the data area (pBuf) provided by the caller. */
PCOUNTRYCODE   pcc;  /* A pointer to the COUNTRYCODE structure in which the country code and code page are identified. */
PCOUNTRYCODE pcc;  /* A pointer to the COUNTRYCODE structure in which the country code
PCHAR           pBuf;  /* The data area where the country-dependent information for the DBCS environmental vector is returned. */
                      and code page are identified. */
APIRET         ulrc;  /* Return Code. */
PCHAR       pBuf;  /* The data area where the country-dependent information for the  
                      DBCS environmental vector is returned. */
APIRET       ulrc;  /* Return Code. */


ulrc = DosQueryDBCSEnv(cb, pcc, pBuf);
ulrc = DosQueryDBCSEnv(cb, pcc, pBuf);
</PRE>
</PRE>
==Parameters==
==Parameters==
; cb (ULONG) - input : The length, in bytes, of the data area (pBuf) provided by the caller.
;cb (ULONG) - input : The length, in bytes, of the data area (pBuf) provided by the caller.
 
:A length value of 12 bytes is sufficient. The caller can always determine if all of the information has been obtained, because it ends with four bytes of 0s. A length of 4 is sufficient for information returned from non-DBCS-related countries.
A length value of 12 bytes is sufficient. The caller can always determine if all of the information has been obtained, because it ends with four bytes of 0s. A length of 4 is sufficient for information returned from non-DBCS-related countries.  
;pcc (PCOUNTRYCODE) - input :  A pointer to the COUNTRYCODE structure in which the country code and code page are identified.
 
:If country is set to 0, the DBCS information for the default system country code is returned.
; pcc (PCOUNTRYCODE) - input :  A pointer to the COUNTRYCODE structure in which the country code and code page are identified.
:If codepage is set to 0, the DBCS information for the current process code page of the caller is returned.
 
:Refer to the [[COUNTRYCODE]] for a table of values for country code and code page identifier.  
If country is set to 0, the DBCS information for the default system country code is returned.
;pBuf (PCHAR) - output : The data area where the country-dependent information for the DBCS environmental vector is returned.
 
:The caller provides this memory area. The size of the area is specified by the input parameter cb.
If codepage is set to 0, the DBCS information for the current process code page of the caller is returned.
:If this area is too small to hold all of the available information, then as much information as possible is provided in the available space (in the order in which the data would appear). Assuming that the data area is large enough, the valid information is terminated by two bytes of 0. The format of the information returned in this buffer is as follows:
 
Refer to the COUNTRYCODE for a table of values for country code and code page identifier.  
 
; pBuf (PCHAR) - output : The data area where the country-dependent information for the DBCS environmental vector is returned.
 
The caller provides this memory area. The size of the area is specified by the input parameter cb.
 
If this area is too small to hold all of the available information, then as much information as possible is provided in the available space (in the order in which the data would appear). Assuming that the data area is large enough, the valid information is terminated by two bytes of 0. The format of the information returned in this buffer is as follows:
 
  2 Bytes        First range definition for DBCS lead byte values:
  2 Bytes        First range definition for DBCS lead byte values:
                 Byte 1            binary start value (inclusive) for range one  
                 Byte 1            binary start value (inclusive) for range one  
Line 51: Line 43:
                                 DB  E0H,FCH
                                 DB  E0H,FCH
                                 DB  0,0
                                 DB  0,0


==Return Code==
==Return Code==
  ulrc (APIRET) - returns
  ulrc (APIRET) - returns
DosQueryDBCSEnv returns one of the following values:
DosQueryDBCSEnv returns one of the following values:
 
* 0 NO_ERROR
* 0         NO_ERROR  
* 397 ERROR_NLS_OPEN_FAILED
* 397       ERROR_NLS_OPEN_FAILED  
* 398 ERROR_NLS_NO_CTRY_CODE
* 398       ERROR_NLS_NO_CTRY_CODE  
* 399 ERROR_NLS_TABLE_TRUNCATED  
* 399       ERROR_NLS_TABLE_TRUNCATED  
* 401 ERROR_NLS_TYPE_NOT_FOUND  
* 401       ERROR_NLS_TYPE_NOT_FOUND  
* 476 ERROR_CODE_PAGE_NOT_FOUND
* 476       ERROR_CODE_PAGE_NOT_FOUND


==Remarks==
==Remarks==
Line 109: Line 97:
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:DosQueryCp|DosQueryCp]]
*[[DosQueryCp]]
* [[OS2 API:CPI:DosQueryCtryInfo|DosQueryCtryInfo]]
*[[DosQueryCtryInfo]]
* [[OS2 API:CPI:DosSetProcessCp|DosSetProcessCp]]
*[[DosSetProcessCp]]
 


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

Revision as of 22:12, 1 December 2016

Description

Obtains a DBCS (double-byte character set) environmental vector that resides in the country file.

Syntax

#define INCL_DOSNLS
#include <os2.h>

ULONG        cb;    /* The length, in bytes, of the data area (pBuf) provided by the caller. */
PCOUNTRYCODE pcc;   /* A pointer to the COUNTRYCODE structure in which the country code
                       and code page are identified. */
PCHAR        pBuf;  /* The data area where the country-dependent information for the 
                       DBCS environmental vector is returned. */
APIRET       ulrc;  /* Return Code. */

ulrc = DosQueryDBCSEnv(cb, pcc, pBuf);

Parameters

cb (ULONG) - input
The length, in bytes, of the data area (pBuf) provided by the caller.
A length value of 12 bytes is sufficient. The caller can always determine if all of the information has been obtained, because it ends with four bytes of 0s. A length of 4 is sufficient for information returned from non-DBCS-related countries.
pcc (PCOUNTRYCODE) - input
A pointer to the COUNTRYCODE structure in which the country code and code page are identified.
If country is set to 0, the DBCS information for the default system country code is returned.
If codepage is set to 0, the DBCS information for the current process code page of the caller is returned.
Refer to the COUNTRYCODE for a table of values for country code and code page identifier.
pBuf (PCHAR) - output
The data area where the country-dependent information for the DBCS environmental vector is returned.
The caller provides this memory area. The size of the area is specified by the input parameter cb.
If this area is too small to hold all of the available information, then as much information as possible is provided in the available space (in the order in which the data would appear). Assuming that the data area is large enough, the valid information is terminated by two bytes of 0. The format of the information returned in this buffer is as follows:
2 Bytes        First range definition for DBCS lead byte values:
               Byte 1            binary start value (inclusive) for range one 
               Byte 2            binary stop value (inclusive) for range one 

2 Bytes        Second range definition:
               Byte 1            binary start value for range two 
               Byte 2            binary stop value for range two 

2 Bytes        Nth range definition:
               Byte 1            binary start value for Nth range 
               Byte 2            binary stop value for Nth range 

2 Bytes        Two bytes of binary 0 end the list.
                   For example: DB   81H,9FH
                                DB   E0H,FCH
                                DB   0,0

Return Code

ulrc (APIRET) - returns

DosQueryDBCSEnv returns one of the following values:

  • 0 NO_ERROR
  • 397 ERROR_NLS_OPEN_FAILED
  • 398 ERROR_NLS_NO_CTRY_CODE
  • 399 ERROR_NLS_TABLE_TRUNCATED
  • 401 ERROR_NLS_TYPE_NOT_FOUND
  • 476 ERROR_CODE_PAGE_NOT_FOUND

Remarks

DosQueryDBCSEnv obtains a double-byte character set environmental vector that resides in the country file (the default name is COUNTRY.SYS).

The vector returned corresponds to the system country code or selected country code, and to the process code page or selected code page.

A double-byte character set is for a code page that contains more than 256 characters. A DBCS data string may contain both SBCS (single-byte character set) and DBCS (double-byte character set) characters.

A DBCS character is two bytes in length. It contains a lead byte and a trail byte. A lead byte is in the range returned by DosQueryDBCSEnv. A trail byte is not restricted to any range. The trail byte always follows the lead byte in a DBCS character.

Example Code

This example shows how to get the double-byte character set vector from the country file, and displays the first and second range definition values.

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

int main(VOID) {
COUNTRYCODE  ctrycodeInfo      = {0};        /* Country code information */
UCHAR        uchDBCSInfo[12]   = {0};        /* DBCS information buffer */
APIRET       rc                = NO_ERROR;   /* A return code */

ctrycodeInfo.country = 0;    /* Current country */
ctrycodeInfo.codepage = 0;   /* Current codepage */

rc = DosQueryDBCSEnv(sizeof(uchDBCSInfo),   /* Size of buffer */
                     &ctrycodeInfo,         /* Country code information */
                     uchDBCSInfo);          /* DBCS information buffer */

if (rc != NO_ERROR) {
   printf("DosQueryDBCSEnv error: return code = %u\n", rc);
   return 1;
 } else {
      /* For non-DBCS countries, these will be 4 bytes of 0 */
   printf("DBCS 1st range definition: %2.2x %2.2x\n",
                            uchDBCSInfo[0], uchDBCSInfo[1]);
   printf("     2nd range definition: %2.2x %2.2x\n",
                            uchDBCSInfo[2], uchDBCSInfo[3]);
 } /* endif */


return NO_ERROR;
}

Related Functions