Jump to content

UniQueryAttr

From EDM2

UniQueryAttr returns the value associated with the attribute name supplied by the user.

Syntax

UniQueryAttr (attrName)

Parameters

attrName (UniChar*)
The name of a character attribute.

Returns

Return value (ULONG)

If the attribute name is known, the function returns the attribute value. Otherwise, 0 is returned.

Remarks

This function provides the numeric value for the standard attributes such as alpha, graph, and number. In addition, this function provides the numeric value for other attributes such as hiragana, diacritic, halfwidth etc. The table below contains the valid attribute names. Valid names are all in lower case.

Attributes whose names begin with a lower-case letter may be ORed together. Attribute names that have a leading _ or # character represent classes of characters; these attributes must be tested as individual attributes.

Symbolic names beginning with "C1_" are provided as aliases for several POSIX attributes for Win32 compatibility.

Attribute Name and Description Table
Attr Name Attribute Define Description of Attribute
alnum CT_ALNUM Alphabetic and numeric characters
alpha CT_ALPHA
C1_ALPHA
Letters and linguistic marks
ascii CT_ASCII Standard ASCII character
blank CT_BLANK
C1_BLANK
Space and Tab
cntrl CT_CNTRL
C1_CNTRL
Control and format characters
diacritic C3_DIACRITIC Diacritic
digit CT_DIGIT
C1_DIGIT
Digits 0 through 9
fullwidth C3_FULLWIDTH Full width variant
graph CT_GRAPH All except controls and space
halfwidth C3_HALFWIDTH Half width variant
hiragana C3_HIRAGANA Hiragana character
ideograph C3_IDEOGRAPH Kanji/Han character
kashida C3_KASHIDA Arabic tatweel (used to stretch characters)
katakana C3_KATAKANA Katakana character
lower CT_LOWER
C1_LOWER
Lower case alphabetic character
nonspacing C3_NONSPACING Non-spacing mark
nsdiacritic C3_NSDIACRITIC Non-spacing diacritic
nsvowel C3_NSVOWEL Non-spacing vowel
number CT_NUMBER Integers between 0 and 9
print CT_PRINT Everything except control characters
punct CT_PUNCT
C1_PUNCT
Punctuation marks
space CT_SPACE
C1_SPACE
Whitespace and line ends
symbol CT_SYMBOL Symbol
upper CT_UPPER
C1_UPPER
Upper case alphabetic character
vowelmark C3_VOWELMARK Vowel mark
xdigit CT_XDIGIT
C1_XDIGIT
Hexadecimal digits (0-9, a-f or A-F)
_apl CHS_APL APL character
_arabic CHS_ARABIC Arabic character
_arrow CHS_ARROW Arrow character
_bengali CHS_BENGALI Bengali character
_bopomofo CHS_BOPOMOFO Bopomofo character
_box CHS_BOX Box or line drawing character
_currency CHS_CURRENCY Currency Symbol
_cyrillic CHS_CYRILLIC Cyrillic character
_dash CHS_DASH Dash character
_devanagari CHS_DEVANAGARI Devanagari character
_dingbat CHS_DINGBAT Dingbat
_fraction CHS_FRACTION Fraction value
_greek CHS_GREEK Greek character
_gujarati CHS_GUJARATI Gujarati character
_gurmukhi CHS_GURMUKHI Gurmukhi character
_hanguel CHS_HANGUEL Hanguel character
_hebrew CHS_HEBREW Hebrew character
_hiragana CHS_HIRAGANA Hiragana character set
_katakana CHS_KATAKANA Katakana character set
_lao CHS_LAO Laotian character
_latin CHS_LATIN Latin character
_linesep CHS_LINESEP Line separator
_math CHS_MATH Math symbol
_punctstart CHS_PUNCTSTART Punctuation start
_punctend CHS_PUNCTEND Punctuation end
_tamil CHS_TAMIL Tamil character
_telegu CHS_TELEGU Telegu character
_thai CHS_THAI Thai character
_userdef CHS_USERDEF User defined character
#arabicnum C2_ARABICNUMBER Arabic numbers
#blocksep C2_BLOCKSEPARATOR Block separator
#commonsep C2_COMMONSEPARATOR Common separator
#euronum C2_EUROPENUMBER European number
#eurosep C2_EUROPESEPARATOR European separator
#euroterm C2_EUROPETERMINATOR European terminator
#left C2_LEFTTORIGHT Left to right text orientation
#mirrored C2_MIRRORED Symmetrical text orientation
#neutral C2_OTHERNEUTRAL Other neutral
#right C2_RIGHTTOLEFT Right to left text orientation
#whitespace C2_WHITESPACE Whitespace

Example

This example shows how to query character attribute values using the character attributes.

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

int main(void) {

    char    name[33];
    UniChar uname[33];
    UniChar * up;
    char    * cp;
    ulong   rc;

    /* Ask the user for an attribute name */
    printf("Enter attribute name:");
    scanf("%s", &name);
    if (strlen(name) > 32)
      return 1;

    /* Convert name to unicode */
    cp = name;
    up = uname;
    while (*cp) {
      *up++ = (UniChar)(*cp++);
    }
    *up = 0;

    /* Query the attribute and print the value */
    rc = UniQueryAttr(tolower(uname));
    if (rc == 0) {
       printf("UniQueryAttr error: return code = %u\n", rc);
       return 1;
    } else
       printf("%s attribute = %x\n", name, rc);

    return ULS_SUCCESS;
} 

Related Functions