This example shows how to create and use a character attribute object.

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

int main(void) {

LocaleObject locale_object = NULL;
AttrObject   attr_object = NULL;

int          result = 0;
int          rc = ULS_SUCCESS;
UniChar      uni_char = L'c';    /* Unicode lowercase Latin letter c */

         /*****************************************************************/
         /* 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;
         }

         /* Create an attribute object */

         rc = UniCreateAttrObject(locale_object,
                                 (UniChar *)L"alpha xdigit", &attr_object);

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

         /* Make call to determine if character matches attributes */

         result = UniQueryCharAttr(attr_object, uni_char);

         if (result)
           printf("UniChar character %04X matches attributes\n", uni_char);

         else
           printf("UniChar character %04X does not match attributes\n", uni_char);

         return ULS_SUCCESS;


}


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