]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/upluralrules.cpp
2 *****************************************************************************************
3 * Copyright (C) 2010-2012, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *****************************************************************************************
8 #include "unicode/utypes.h"
10 #if !UCONFIG_NO_FORMATTING
12 #include "unicode/upluralrules.h"
13 #include "unicode/plurrule.h"
14 #include "unicode/locid.h"
15 #include "unicode/unistr.h"
20 U_CAPI UPluralRules
* U_EXPORT2
21 uplrules_open(const char *locale
, UErrorCode
*status
)
23 return uplrules_openForType(locale
, UPLURAL_TYPE_CARDINAL
, status
);
26 U_CAPI UPluralRules
* U_EXPORT2
27 uplrules_openForType(const char *locale
, UPluralType type
, UErrorCode
*status
)
29 return (UPluralRules
*)PluralRules::forLocale(Locale(locale
), type
, *status
);
33 uplrules_close(UPluralRules
*uplrules
)
35 delete (PluralRules
*)uplrules
;
38 U_CAPI
int32_t U_EXPORT2
39 uplrules_select(const UPluralRules
*uplrules
,
41 UChar
*keyword
, int32_t capacity
,
44 if (U_FAILURE(*status
)) {
47 if (keyword
== NULL
? capacity
!= 0 : capacity
< 0) {
48 *status
= U_ILLEGAL_ARGUMENT_ERROR
;
51 UnicodeString result
= ((PluralRules
*)uplrules
)->select(number
);
52 return result
.extract(keyword
, capacity
, *status
);
56 #endif /* #if !UCONFIG_NO_FORMATTING */