Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: source/common/pluralmap.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/common/pluralmap.h ('k') | source/common/propname_data.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2015, International Business Machines Corporation and
3 * others. All Rights Reserved.
4 */
5
6 #include "unicode/unistr.h"
7 #include "charstr.h"
8 #include "cstring.h"
9 #include "pluralmap.h"
10
11 U_NAMESPACE_BEGIN
12
13 static const char * const gPluralForms[] = {
14 "other", "zero", "one", "two", "few", "many"};
15
16 PluralMapBase::Category
17 PluralMapBase::toCategory(const char *pluralForm) {
18 for (int32_t i = 0; i < UPRV_LENGTHOF(gPluralForms); ++i) {
19 if (uprv_strcmp(pluralForm, gPluralForms[i]) == 0) {
20 return static_cast<Category>(i);
21 }
22 }
23 return NONE;
24 }
25
26 PluralMapBase::Category
27 PluralMapBase::toCategory(const UnicodeString &pluralForm) {
28 CharString cCategory;
29 UErrorCode status = U_ZERO_ERROR;
30 cCategory.appendInvariantChars(pluralForm, status);
31 return U_FAILURE(status) ? NONE : toCategory(cCategory.data());
32 }
33
34 const char *PluralMapBase::getCategoryName(Category c) {
35 int32_t index = c;
36 return (index < 0 || index >= UPRV_LENGTHOF(gPluralForms)) ?
37 NULL : gPluralForms[index];
38 }
39
40
41 U_NAMESPACE_END
42
OLDNEW
« no previous file with comments | « source/common/pluralmap.h ('k') | source/common/propname_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698