Jump to content

DosQueryCollate: Difference between revisions

From EDM2
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 (pch) provided by the caller. */
ULONG         cb;    /* The length, in bytes, of the data area (pch) provided by the caller. */
PCOUNTRYCODE   pcc;  /* Pointer to the COUNTRYCODE structure in which the country code and code page are identified. */
PCOUNTRYCODE pcc;  /* Pointer to the COUNTRYCODE structure in which the country code  
PCHAR           pch;  /* The data area where the collating sequence table is returned. */
                        and code page are identified. */
PULONG         pcch;  /* The length, in bytes, of the collating sequence table returned. */
PCHAR         pch;  /* The data area where the collating sequence table is returned. */
APIRET         ulrc;  /* Return Code. */
PULONG       pcch;  /* The length, in bytes, of the collating sequence table returned. */
APIRET       ulrc;  /* Return Code. */


ulrc = DosQueryCollate(cb, pcc, pch, pcch);
ulrc = DosQueryCollate(cb, pcc, pch, pcch);
</PRE>


</PRE>
==Parameters==
==Parameters==
; cb (ULONG) - input : The length, in bytes, of the data area (pch) provided by the caller.
;cb (ULONG) - input : The length, in bytes, of the data area (pch) provided by the caller.
 
:A length value of 256 bytes is sufficient.  
A length value of 256 bytes is sufficient.  
;pcc (PCOUNTRYCODE) - input : Pointer to the COUNTRYCODE structure in which the country code and code page are identified.
 
:If country is set to 0, the collate table for the default system country code is returned.
; pcc (PCOUNTRYCODE) - input : Pointer to the COUNTRYCODE structure in which the country code and code page are identified.
:If codepage is set to 0, the collate table 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 collate table for the default system country code is returned.
;pch (PCHAR) - output : The data area where the collating sequence table is returned.
 
:The caller provides this data area. The input parameter cb specifies the length of this area.
If codepage is set to 0, the collate table 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). If the amount of data returned is not enough to fill the memory area provided by the caller, then the memory that is unaltered by the available data is zeroed out. The format of the information returned in this buffer is as follows:
 
  1 Byte Sort weight of ASCII (0)
Refer to the COUNTRYCODE for a table of values for country code and code page identifier.  
  1 Byte Sort weight of ASCII (1)
 
  ...     (additional values in collating order)
; pch (PCHAR) - output : The data area where the collating sequence table is returned.
  1 Byte Sort weight of ASCII (255)
 
;pcch (PULONG) - output : The length, in bytes, of the collating sequence table returned.
The caller provides this data area. The input parameter cb specifies the length of this area.
 
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). If the amount of data returned is not enough to fill the memory area provided by the caller, then the memory that is unaltered by the available data is zeroed out. The format of the information returned in this buffer is as follows:
 
  1 Byte       Sort weight of ASCII (0)  
  1 Byte       Sort weight of ASCII (1)
  ...           (additional values in collating order)  
  1 Byte       Sort weight of ASCII (255)  
 
; pcch (PULONG) - output : The length, in bytes, of the collating sequence table returned.


==Return Code==
==Return Code==
  ulrc (APIRET) - returns
  ulrc (APIRET) - returns
DosQueryCollate returns one of the following values:
DosQueryCollate 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 62: Line 51:
This example gets the collating sequence table for the current country and code page.
This example gets the collating sequence table for the current country and code page.
<PRE>
<PRE>
  #define INCL_DOSNLS    /* National Language Support values */
  #define INCL_DOSNLS    /* National Language Support values */
  #define INCL_DOSERRORS  /* DOS error values                */
  #define INCL_DOSERRORS  /* DOS error values                */
Line 106: Line 93:
   return NO_ERROR;
   return NO_ERROR;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosMapCase|DosMapCase]]
*[[DosMapCase]]
* [[OS2 API:CPI:DosQueryCp|DosQueryCp]]
*[[DosQueryCp]]
* [[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]]

Revision as of 21:51, 1 December 2016

Description

Obtains a collating sequence table that resides in the country file.

Syntax


#define INCL_DOSNLS
#include <os2.h>

ULONG         cb;    /* The length, in bytes, of the data area (pch) provided by the caller. */
PCOUNTRYCODE  pcc;   /* Pointer to the COUNTRYCODE structure in which the country code 
                        and code page are identified. */
PCHAR         pch;   /* The data area where the collating sequence table is returned. */
PULONG        pcch;  /* The length, in bytes, of the collating sequence table returned. */
APIRET        ulrc;  /* Return Code. */

ulrc = DosQueryCollate(cb, pcc, pch, pcch);

Parameters

cb (ULONG) - input
The length, in bytes, of the data area (pch) provided by the caller.
A length value of 256 bytes is sufficient.
pcc (PCOUNTRYCODE) - input
Pointer to the COUNTRYCODE structure in which the country code and code page are identified.
If country is set to 0, the collate table for the default system country code is returned.
If codepage is set to 0, the collate table 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.
pch (PCHAR) - output
The data area where the collating sequence table is returned.
The caller provides this data area. The input parameter cb specifies the length of this area.
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). If the amount of data returned is not enough to fill the memory area provided by the caller, then the memory that is unaltered by the available data is zeroed out. The format of the information returned in this buffer is as follows:
1 Byte  Sort weight of ASCII (0)
1 Byte  Sort weight of ASCII (1)
...     (additional values in collating order)
1 Byte  Sort weight of ASCII (255)
pcch (PULONG) - output
The length, in bytes, of the collating sequence table returned.

Return Code

ulrc (APIRET) - returns

DosQueryCollate 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

DosQueryCollate obtains a collating sequence table (for characters 0x00 through 0xFF) that resides in the country file (the default name is COUNTRY.SYS). It is used by the SORT utility to sort text according to the collating sequence.

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

Example Code

This example gets the collating sequence table for the current country and code page.

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

 int main(VOID) {
 COUNTRYCODE UserInfo       = {0};       /* Country and code page requested */
 UCHAR       achColSeq[256] = {0};       /* Collating sequence              */
 ULONG       ulSeqLen       = 0;         /* Length of sequence returned     */
 ULONG       i              = 0,         /* Two loop indices                */
             j              = 0;
 APIRET      rc             = NO_ERROR;  /* Return code                     */

    UserInfo.country = 0;      /* Request information about current country */
    UserInfo.codepage = 0;     /* ... and current code page                 */

    rc = DosQueryCollate(sizeof(achColSeq),   /* Length of output area      */
                         &UserInfo,           /* Country and codepage info  */
                         achColSeq,           /* Area for collating sequence*/
                         &ulSeqLen);          /* Length of data returned    */

    if (rc != NO_ERROR) {
        printf("DosQueryCollate error: return code = %u\n",rc);
        return 1;
    }
         /* Show the order of the first 128 characters in the sequence */

   if (ulSeqLen >= 8*16) {
     for (i = 0; i < 8; i++) {
       for (j = 0; j < 16; j++) {
          printf("%3u ", achColSeq[i*16+j]);
          } /* endfor (j) */
       printf("\n");
       } /* endfor (i) */
   } else {
      printf("Unable to show first 128 characters... only %u were returned.\n",
              ulSeqLen);
      return 1;
   }  /* endif */

   return NO_ERROR;
}

Related Functions