home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nlsnps.zip / nlsInitialize.cpp < prev    next >
C/C++ Source or Header  |  1996-09-03  |  991b  |  42 lines

  1. #define INCL_DOSNLS
  2. #include <os2.h>
  3. #include <memory.h>
  4. #include "nls.h"
  5.  
  6. void nlsInitialize()
  7. {  static COUNTRYCODE countrycode = { 0, 0 };
  8.    UCHAR abVectorBuffer[12];
  9.  
  10.    memset(AfbDBCS, 0, sizeof(AfbDBCS));
  11.  
  12.    if (DosQueryDBCSEnv(sizeof(abVectorBuffer), &countrycode, abVectorBuffer) == 0)
  13.    {  PUCHAR pb = abVectorBuffer;
  14.  
  15.       while (*(short *)pb != 0)
  16.       {  memset(AfbDBCS + pb[0], 1, pb[1] - pb[0] + 1);
  17.      pb += 2;
  18.       }
  19.    }
  20.  
  21.    for (UINT ui = 0; ui < 256; ui++)
  22.    {  AbUpperChars[ui] = AbLowerChars[ui] = ui;
  23.  
  24.       if (ui >= 0x20 && AfbDBCS[ui] == 0)
  25.       {  DosMapCase(1, &countrycode, &AbUpperChars[ui]);
  26.       }
  27.    }
  28.  
  29.    for (ui = 0x20; ui < 256; ui++)
  30.    {  UINT uiUpper;
  31.  
  32.       if (AfbDBCS[ui] == 0
  33.       && (uiUpper = AbUpperChars[ui]) != ui
  34.       && AbLowerChars[uiUpper] == uiUpper)
  35.       {  AbLowerChars[uiUpper] = ui;
  36.       }
  37.    }
  38.  
  39.    ULONG ulTemp;
  40.    DosQueryCollate(sizeof(AbCollate), &countrycode, AbCollate, &ulTemp);
  41. }
  42.