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 enum UPluralType UPluralType
typedef struct UPluralRules UPluralRules
 C typedef for struct UPluralRules.

Enumerations

enum  UPluralType { UPLURAL_TYPE_CARDINAL, UPLURAL_TYPE_ORDINAL, UPLURAL_TYPE_COUNT }
 

Type of plurals and PluralRules.

More...

Functions

UPluralRulesuplrules_open (const char *locale, UErrorCode *status)
 Opens a new UPluralRules object using the predefined cardinal-number plural rules for a given locale.
UPluralRulesuplrules_openForType (const char *locale, UPluralType type, UErrorCode *status)
 Opens a new UPluralRules object using the predefined plural rules for a given locale and the plural type.
void uplrules_close (UPluralRules *uplrules)
 Closes 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.

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 71 of file upluralrules.h.

typedef enum UPluralType UPluralType
Draft:
This API may be changed in the future versions and was introduced in ICU 50

Definition at line 64 of file upluralrules.h.


Enumeration Type Documentation

Type of plurals and PluralRules.

Draft:
This API may be changed in the future versions and was introduced in ICU 50
Enumerator:
UPLURAL_TYPE_CARDINAL 

Plural rules for cardinal numbers: 1 file vs.

2 files.

Draft:
This API may be changed in the future versions and was introduced in ICU 50
UPLURAL_TYPE_ORDINAL 

Plural rules for ordinal numbers: 1st file, 2nd file, 3rd file, 4th file, etc.

Draft:
This API may be changed in the future versions and was introduced in ICU 50
UPLURAL_TYPE_COUNT 

Number of Plural rules types.

Draft:
This API may be changed in the future versions and was introduced in ICU 50

Definition at line 44 of file upluralrules.h.


Function Documentation

void uplrules_close ( UPluralRules uplrules  ) 

Closes a UPluralRules object.

Once closed it may no longer be used.

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

Opens a new UPluralRules object using the predefined cardinal-number plural rules for a given locale.

Same as uplrules_openForType(locale, UPLURAL_TYPE_CARDINAL, status).

Parameters:
locale The locale for which the rules are desired.
status A pointer to a UErrorCode to receive any errors.
Returns:
A UPluralRules for the specified locale, or NULL if an error occurred.
Stable:
ICU 4.8
UPluralRules* uplrules_openForType ( const char *  locale,
UPluralType  type,
UErrorCode status 
)

Opens a new UPluralRules object using the predefined plural rules for a given locale and the plural type.

Parameters:
locale The locale for which the rules are desired.
type The plural type (e.g., cardinal or ordinal).
status A pointer to a UErrorCode to receive any errors.
Returns:
A UPluralRules for the specified locale, or NULL if an error occurred.
Draft:
This API may be changed in the future versions and was introduced in ICU 50
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:
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.
Returns:
The length of keyword.
Stable:
ICU 4.8

Generated on 4 Dec 2017 for ICU 50.1.2 by  doxygen 1.6.1