ICU 49.1.1  49.1.1
Typedefs | Functions
upluralrules.h File Reference

C API: Plural rules, select plural keywords for numeric values. More...

#include "unicode/utypes.h"
#include "unicode/localpointer.h"

Go to the source code of this file.

Typedefs

typedef struct UPluralRules UPluralRules
 C typedef for struct UPluralRules. More...
 

Functions

UPluralRulesuplrules_open (const char *locale, UErrorCode *status)
 Open a new UPluralRules object using the predefined plural rules for a given locale. More...
 
void uplrules_close (UPluralRules *uplrules)
 Close a UPluralRules object. More...
 
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. More...
 

Detailed Description

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 Documentation

typedef struct UPluralRules UPluralRules

C typedef for struct UPluralRules.

Stable:
ICU 4.8

Definition at line 45 of file upluralrules.h.

Function Documentation

void uplrules_close ( UPluralRules uplrules)

Close a UPluralRules object.

Once closed it may no longer be used.

Parameters
uplrulesThe UPluralRules object to close.
Stable:
ICU 4.8
UPluralRules* uplrules_open ( const char *  locale,
UErrorCode status 
)

Open a new UPluralRules object using the predefined plural rules for a given locale.

Parameters
localeThe locale for which the rules are desired.
statusA pointer to a UErrorCode to receive any errors.
Returns
A UPluralRules for the specified locale, or 0 if an error occurred.
Stable:
ICU 4.8
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.

Parameters
uplrulesThe UPluralRules object specifying the rules.
numberThe number for which the rule has to be determined.
keywordThe keyword of the rule that applies to number.
capacityThe capacity of keyword.
statusA pointer to a UErrorCode to receive any errors.
Returns
The length of keyword.
Stable:
ICU 4.8