This example shows how to compare Unicode strings using the collating sequence specified by the locale_object.

#include <stdio.h>
#include <unidef.h>

int main(void) {

LocaleObject locale_object = NULL;

UniChar      ucs1[] = L"axe";
UniChar      ucs2[] = L"ant";
int          result = 0;
int          rc = ULS_SUCCESS;

         /*****************************************************************/
         /* Assumes LANG environment variable set to a valid locale name, */
         /* such as fr_FR                                                 */
         /*****************************************************************/

         rc = UniCreateLocaleObject(UNI_UCS_STRING_POINTER,
                                   (UniChar *)L"", &locale_object);

         if (rc != ULS_SUCCESS) {
           printf("UniCreateLocaleObject error: return code = %u\n", rc);
           return 1;
         }


         result = UniStrcoll(locale_object, ucs1, ucs2);

         if ( result == 0 )
             printf("The strings are identical\n");
         else if ( result < 0 )
             printf("String1 is less than String2\n");
         else
             printf("String1 is greater than String2\n");

         return (ULS_SUCCESS);


}


[Back: UniStrcoll - Related Functions]
[Next: UniStrcoll - Topics]