DosMapCase

From EDM2
Revision as of 15:25, 12 October 2018 by Ak120 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Performs case mapping on a string of binary values that represent ASCII characters.

Syntax

DosMapCase(cb, pcc, pch)

Parameters

cb (ULONG) - input
The length, in bytes, of the string of binary values to be case-mapped.
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 case map table for the default system country code is used.
If codepage is set to 0, the case map table for the current process code page of the caller is used.
Refer to the COUNTRYCODE for a table of values for country code and code page identifier.
pch (PCHAR) - in/out 
The string of binary characters to be case-mapped.
They are case-mapped in place, and they replace the input, so the results appear in pch.

Return Code

ulrc (APIRET) - returns
DosMapCase returns one of the following values:
  • 0 NO_ERROR
  • 397 ERROR_NLS_OPEN_FAILED
  • 398 ERROR_NLS_NO_CTRY_CODE
  • 401 ERROR_NLS_TYPE_NOT_FOUND
  • 476 ERROR_CODE_PAGE_NOT_FOUND

Remarks

DosMapCase performs case mapping on a string of binary values that represent ASCII characters.

The case map in the country file (the default name is COUNTRY.SYS) that corresponds to the system country code or selected country code, and to the process code page or selected code page, is used to perform the case mapping.

Example Code

This example converts a string to uppercase based on the current country settings.

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

#define COUNTRY_CODE 0       /* Country code             (0 = current) */
#define NLS_CODEPAGE 0       /* Code page for conversion (0 = current) */

int main(VOID) {

COUNTRYCODE Country       = {0};        /* Country code  */
CHAR        uchString[80] = "";         /* String        */
APIRET      rc            = 0;          /* Return code   */

   Country.country  = COUNTRY_CODE;     /* Country code  */

   Country.codepage = NLS_CODEPAGE;     /* Code page     */

   strcpy(uchString, "Capitalize this entire sTrInG, please!");

   printf("Original string is:  %s\n", uchString);

   rc = DosMapCase(sizeof(uchString),   /* Length of string to convert */
                   &Country,            /* Country and code page info  */
                   uchString);          /* String to convert           */

   if (rc != NO_ERROR) {
      printf("DosMapCase error: return code = %u\n", rc);
      return 1;
   } else {
      printf("Converted string is: %s\n", uchString);
   } /* endif */

   return NO_ERROR;
}

Related Functions