ICU 49.1.1
49.1.1
|
C API: Plural rules, select plural keywords for numeric values. More...
Go to the source code of this file.
Typedefs | |
typedef struct UPluralRules | UPluralRules |
C typedef for struct UPluralRules. |
Functions | |
UPluralRules * | uplrules_open (const char *locale, UErrorCode *status) |
Open a new UPluralRules object using the predefined plural rules for a given locale. | |
void | uplrules_close (UPluralRules *uplrules) |
Close a UPluralRules object. | |
int32_t | uplrules_select (const UPluralRules *uplrules, double number, UChar *keyword, int32_t capacity, UErrorCode *status) |
Given a number, returns the keyword of the first rule that applies to the number, according to the supplied UPluralRules object. |
C API: Plural rules, select plural keywords for numeric values.
A UPluralRules object defines rules for mapping non-negative numeric values onto a small set of keywords. Rules are constructed from a text description, consisting of a series of keywords and conditions. The uplrules_select function examines each condition in order and returns the keyword for the first condition that matches the number. If none match, the default rule(other) is returned.
For more information, see the LDML spec, C.11 Language Plural Rules: http://www.unicode.org/reports/tr35/#Language_Plural_Rules
Keywords: ICU locale data has 6 predefined values - 'zero', 'one', 'two', 'few', 'many' and 'other'. Callers need to check the value of keyword returned by the uplrules_select function.
These are based on CLDR Language Plural Rules. For these predefined rules, see the CLDR page at http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
Definition in file upluralrules.h.
typedef struct UPluralRules UPluralRules |
void uplrules_close | ( | UPluralRules * | uplrules | ) |
Close a UPluralRules object.
Once closed it may no longer be used.
uplrules | The UPluralRules object to close. |
UPluralRules* uplrules_open | ( | const char * | locale, |
UErrorCode * | status | ||
) |
Open a new UPluralRules object using the predefined plural rules for a given locale.
locale | The locale for which the rules are desired. |
status | A pointer to a UErrorCode to receive any errors. |
int32_t uplrules_select | ( | const UPluralRules * | uplrules, |
double | number, | ||
UChar * | keyword, | ||
int32_t | capacity, | ||
UErrorCode * | status | ||
) |
Given a number, returns the keyword of the first rule that applies to the number, according to the supplied UPluralRules object.
uplrules | The UPluralRules object specifying the rules. |
number | The number for which the rule has to be determined. |
keyword | The keyword of the rule that applies to number. |
capacity | The capacity of keyword. |
status | A pointer to a UErrorCode to receive any errors. |