3.8 Example: NWUnicodeCompare

   /* exucomp.c  -  NWUnicodeCompare example. 
      Compare 2 unicode characters in collation sequence. 
   */ 
   #define NWL_EXCLUDE_TIME 
   #define NWL_EXCLUDE_FILE 
   #include <nwlocale.h> 
   #include <unicode.h> 
   #include <assert.h> 
   void main() 
   { 
      LCONV lconv; 
      nint ret; 
      nptr h = NULL; 
   
      /* Get the country ID and code page from the operating system. */ 
      NWLlocaleconv(&lconv); 
      ret = NWInitUnicodeTables(lconv.country_id, lconv.code_page); 
      assert (ret == 0); 
      ret = NWGetCollationHandle(&h); 
      assert (ret == 0); 
      ret = NWUnicodeCompare(h, ’A’, ’B’); 
      assert (ret == -1);                    /* A < B */ 
   
   /* On WNT, it calls StringCompareW, which considers a < A. 
      The collation order is  ...aA..bB..cC... 
   */ 
   
   #ifdef N_PLAT_WNT 
      ret = NWUnicodeCompare(h, ’A’, ’a’); 
      assert (ret == 1);                     /* A > a */ 
      ret = NWUnicodeCompare(h, ’a’, ’B’); 
      assert (ret == -1); 
      ret = NWUnicodeCompare(h, ’B’, ’a’); 
      assert (ret == 1); 
   
   /* On W95, it calls wcsxfrm, which considers A < a. 
      The collation order is the same as the character value: 
         ...ABC..Z..abc..z... 
   */ 
   
   #elif defined WIN32 
      ret = NWUnicodeCompare(h, ’A’, ’a’); 
      assert (ret == -1);                     /* A < a */ 
      ret = NWUnicodeCompare(h, ’a’, ’B’); 
      assert (ret == 1); 
      ret = NWUnicodeCompare(h, ’B’, ’a’); 
      assert (ret ==-1); 
   
   /* On NLM it uses the Novell collation tables. 
      Upper and lowercase letters are considered equal. 
   */ 
   
   #else 
      ret = NWUnicodeCompare(h, ’A’, ’a’); 
      assert (ret == 0);                     /* A < a */ 
      ret = NWUnicodeCompare(h, ’a’, ’B’); 
      assert (ret == -1); 
      ret = NWUnicodeCompare(h, ’B’, ’a’); 
      assert (ret ==1); 
   #endif 
      NWFreeUnicodeTables(); 
   }