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

Side by Side Diff: Source/WTF/wtf/unicode/icu/UnicodeIcu.h

Issue 14238015: Move Source/WTF/wtf to Source/wtf (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2006 George Staikos <staikos@kde.org>
3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
4 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #ifndef WTF_UNICODE_ICU_H
24 #define WTF_UNICODE_ICU_H
25
26 #if USE(ICU_UNICODE)
27
28 #include <stdlib.h>
29 #include <unicode/uchar.h>
30 #include <unicode/uscript.h>
31 #include <unicode/ustring.h>
32 #include <unicode/utf16.h>
33
34 namespace WTF {
35
36 namespace Unicode {
37
38 enum Direction {
39 LeftToRight = U_LEFT_TO_RIGHT,
40 RightToLeft = U_RIGHT_TO_LEFT,
41 EuropeanNumber = U_EUROPEAN_NUMBER,
42 EuropeanNumberSeparator = U_EUROPEAN_NUMBER_SEPARATOR,
43 EuropeanNumberTerminator = U_EUROPEAN_NUMBER_TERMINATOR,
44 ArabicNumber = U_ARABIC_NUMBER,
45 CommonNumberSeparator = U_COMMON_NUMBER_SEPARATOR,
46 BlockSeparator = U_BLOCK_SEPARATOR,
47 SegmentSeparator = U_SEGMENT_SEPARATOR,
48 WhiteSpaceNeutral = U_WHITE_SPACE_NEUTRAL,
49 OtherNeutral = U_OTHER_NEUTRAL,
50 LeftToRightEmbedding = U_LEFT_TO_RIGHT_EMBEDDING,
51 LeftToRightOverride = U_LEFT_TO_RIGHT_OVERRIDE,
52 RightToLeftArabic = U_RIGHT_TO_LEFT_ARABIC,
53 RightToLeftEmbedding = U_RIGHT_TO_LEFT_EMBEDDING,
54 RightToLeftOverride = U_RIGHT_TO_LEFT_OVERRIDE,
55 PopDirectionalFormat = U_POP_DIRECTIONAL_FORMAT,
56 NonSpacingMark = U_DIR_NON_SPACING_MARK,
57 BoundaryNeutral = U_BOUNDARY_NEUTRAL
58 };
59
60 enum DecompositionType {
61 DecompositionNone = U_DT_NONE,
62 DecompositionCanonical = U_DT_CANONICAL,
63 DecompositionCompat = U_DT_COMPAT,
64 DecompositionCircle = U_DT_CIRCLE,
65 DecompositionFinal = U_DT_FINAL,
66 DecompositionFont = U_DT_FONT,
67 DecompositionFraction = U_DT_FRACTION,
68 DecompositionInitial = U_DT_INITIAL,
69 DecompositionIsolated = U_DT_ISOLATED,
70 DecompositionMedial = U_DT_MEDIAL,
71 DecompositionNarrow = U_DT_NARROW,
72 DecompositionNoBreak = U_DT_NOBREAK,
73 DecompositionSmall = U_DT_SMALL,
74 DecompositionSquare = U_DT_SQUARE,
75 DecompositionSub = U_DT_SUB,
76 DecompositionSuper = U_DT_SUPER,
77 DecompositionVertical = U_DT_VERTICAL,
78 DecompositionWide = U_DT_WIDE,
79 };
80
81 enum CharCategory {
82 NoCategory = 0,
83 Other_NotAssigned = U_MASK(U_GENERAL_OTHER_TYPES),
84 Letter_Uppercase = U_MASK(U_UPPERCASE_LETTER),
85 Letter_Lowercase = U_MASK(U_LOWERCASE_LETTER),
86 Letter_Titlecase = U_MASK(U_TITLECASE_LETTER),
87 Letter_Modifier = U_MASK(U_MODIFIER_LETTER),
88 Letter_Other = U_MASK(U_OTHER_LETTER),
89
90 Mark_NonSpacing = U_MASK(U_NON_SPACING_MARK),
91 Mark_Enclosing = U_MASK(U_ENCLOSING_MARK),
92 Mark_SpacingCombining = U_MASK(U_COMBINING_SPACING_MARK),
93
94 Number_DecimalDigit = U_MASK(U_DECIMAL_DIGIT_NUMBER),
95 Number_Letter = U_MASK(U_LETTER_NUMBER),
96 Number_Other = U_MASK(U_OTHER_NUMBER),
97
98 Separator_Space = U_MASK(U_SPACE_SEPARATOR),
99 Separator_Line = U_MASK(U_LINE_SEPARATOR),
100 Separator_Paragraph = U_MASK(U_PARAGRAPH_SEPARATOR),
101
102 Other_Control = U_MASK(U_CONTROL_CHAR),
103 Other_Format = U_MASK(U_FORMAT_CHAR),
104 Other_PrivateUse = U_MASK(U_PRIVATE_USE_CHAR),
105 Other_Surrogate = U_MASK(U_SURROGATE),
106
107 Punctuation_Dash = U_MASK(U_DASH_PUNCTUATION),
108 Punctuation_Open = U_MASK(U_START_PUNCTUATION),
109 Punctuation_Close = U_MASK(U_END_PUNCTUATION),
110 Punctuation_Connector = U_MASK(U_CONNECTOR_PUNCTUATION),
111 Punctuation_Other = U_MASK(U_OTHER_PUNCTUATION),
112
113 Symbol_Math = U_MASK(U_MATH_SYMBOL),
114 Symbol_Currency = U_MASK(U_CURRENCY_SYMBOL),
115 Symbol_Modifier = U_MASK(U_MODIFIER_SYMBOL),
116 Symbol_Other = U_MASK(U_OTHER_SYMBOL),
117
118 Punctuation_InitialQuote = U_MASK(U_INITIAL_PUNCTUATION),
119 Punctuation_FinalQuote = U_MASK(U_FINAL_PUNCTUATION)
120 };
121
122 inline UChar32 foldCase(UChar32 c)
123 {
124 return u_foldCase(c, U_FOLD_CASE_DEFAULT);
125 }
126
127 inline int foldCase(UChar* result, int resultLength, const UChar* src, int srcLe ngth, bool* error)
128 {
129 UErrorCode status = U_ZERO_ERROR;
130 int realLength = u_strFoldCase(result, resultLength, src, srcLength, U_FOLD_ CASE_DEFAULT, &status);
131 *error = !U_SUCCESS(status);
132 return realLength;
133 }
134
135 inline int toLower(UChar* result, int resultLength, const UChar* src, int srcLen gth, bool* error)
136 {
137 UErrorCode status = U_ZERO_ERROR;
138 int realLength = u_strToLower(result, resultLength, src, srcLength, "", &sta tus);
139 *error = !!U_FAILURE(status);
140 return realLength;
141 }
142
143 inline UChar32 toLower(UChar32 c)
144 {
145 return u_tolower(c);
146 }
147
148 inline UChar32 toUpper(UChar32 c)
149 {
150 return u_toupper(c);
151 }
152
153 inline int toUpper(UChar* result, int resultLength, const UChar* src, int srcLen gth, bool* error)
154 {
155 UErrorCode status = U_ZERO_ERROR;
156 int realLength = u_strToUpper(result, resultLength, src, srcLength, "", &sta tus);
157 *error = !!U_FAILURE(status);
158 return realLength;
159 }
160
161 inline UChar32 toTitleCase(UChar32 c)
162 {
163 return u_totitle(c);
164 }
165
166 inline bool isArabicChar(UChar32 c)
167 {
168 return ublock_getCode(c) == UBLOCK_ARABIC;
169 }
170
171 inline bool isAlphanumeric(UChar32 c)
172 {
173 return u_isalnum(c);
174 }
175
176 inline bool isSeparatorSpace(UChar32 c)
177 {
178 return u_charType(c) == U_SPACE_SEPARATOR;
179 }
180
181 inline bool isPrintableChar(UChar32 c)
182 {
183 return !!u_isprint(c);
184 }
185
186 inline bool isPunct(UChar32 c)
187 {
188 return !!u_ispunct(c);
189 }
190
191 inline bool hasLineBreakingPropertyComplexContext(UChar32 c)
192 {
193 return u_getIntPropertyValue(c, UCHAR_LINE_BREAK) == U_LB_COMPLEX_CONTEXT;
194 }
195
196 inline UChar32 mirroredChar(UChar32 c)
197 {
198 return u_charMirror(c);
199 }
200
201 inline CharCategory category(UChar32 c)
202 {
203 return static_cast<CharCategory>(U_GET_GC_MASK(c));
204 }
205
206 inline Direction direction(UChar32 c)
207 {
208 return static_cast<Direction>(u_charDirection(c));
209 }
210
211 inline bool isLower(UChar32 c)
212 {
213 return !!u_islower(c);
214 }
215
216 inline uint8_t combiningClass(UChar32 c)
217 {
218 return u_getCombiningClass(c);
219 }
220
221 inline DecompositionType decompositionType(UChar32 c)
222 {
223 return static_cast<DecompositionType>(u_getIntPropertyValue(c, UCHAR_DECOMPO SITION_TYPE));
224 }
225
226 inline int umemcasecmp(const UChar* a, const UChar* b, int len)
227 {
228 return u_memcasecmp(a, b, len, U_FOLD_CASE_DEFAULT);
229 }
230
231 } // namespace Unicode
232
233 } // namespace WTF
234
235 #endif // USE(ICU_UNICODE)
236
237 #endif // WTF_UNICODE_ICU_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698