2 * Copyright (C) 2006 George Staikos <staikos@kde.org>
3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
4 * Copyright (C) 2007 Apple Computer, Inc. All rights reserved.
5 * Copyright (C) 2007-2009 Torch Mobile, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef WTF_UnicodeWinCE_h
25 #define WTF_UnicodeWinCE_h
27 #include "UnicodeMacrosFromICU.h"
29 #include "ce_unicode.h"
31 #define TO_MASK(x) (1 << (x))
37 LeftToRight
= UnicodeCE::U_LEFT_TO_RIGHT
,
38 RightToLeft
= UnicodeCE::U_RIGHT_TO_LEFT
,
39 EuropeanNumber
= UnicodeCE::U_EUROPEAN_NUMBER
,
40 EuropeanNumberSeparator
= UnicodeCE::U_EUROPEAN_NUMBER_SEPARATOR
,
41 EuropeanNumberTerminator
= UnicodeCE::U_EUROPEAN_NUMBER_TERMINATOR
,
42 ArabicNumber
= UnicodeCE::U_ARABIC_NUMBER
,
43 CommonNumberSeparator
= UnicodeCE::U_COMMON_NUMBER_SEPARATOR
,
44 BlockSeparator
= UnicodeCE::U_BLOCK_SEPARATOR
,
45 SegmentSeparator
= UnicodeCE::U_SEGMENT_SEPARATOR
,
46 WhiteSpaceNeutral
= UnicodeCE::U_WHITE_SPACE_NEUTRAL
,
47 OtherNeutral
= UnicodeCE::U_OTHER_NEUTRAL
,
48 LeftToRightEmbedding
= UnicodeCE::U_LEFT_TO_RIGHT_EMBEDDING
,
49 LeftToRightOverride
= UnicodeCE::U_LEFT_TO_RIGHT_OVERRIDE
,
50 RightToLeftArabic
= UnicodeCE::U_RIGHT_TO_LEFT_ARABIC
,
51 RightToLeftEmbedding
= UnicodeCE::U_RIGHT_TO_LEFT_EMBEDDING
,
52 RightToLeftOverride
= UnicodeCE::U_RIGHT_TO_LEFT_OVERRIDE
,
53 PopDirectionalFormat
= UnicodeCE::U_POP_DIRECTIONAL_FORMAT
,
54 NonSpacingMark
= UnicodeCE::U_DIR_NON_SPACING_MARK
,
55 BoundaryNeutral
= UnicodeCE::U_BOUNDARY_NEUTRAL
58 enum DecompositionType
{
59 DecompositionNone
= UnicodeCE::U_DT_NONE
,
60 DecompositionCanonical
= UnicodeCE::U_DT_CANONICAL
,
61 DecompositionCompat
= UnicodeCE::U_DT_COMPAT
,
62 DecompositionCircle
= UnicodeCE::U_DT_CIRCLE
,
63 DecompositionFinal
= UnicodeCE::U_DT_FINAL
,
64 DecompositionFont
= UnicodeCE::U_DT_FONT
,
65 DecompositionFraction
= UnicodeCE::U_DT_FRACTION
,
66 DecompositionInitial
= UnicodeCE::U_DT_INITIAL
,
67 DecompositionIsolated
= UnicodeCE::U_DT_ISOLATED
,
68 DecompositionMedial
= UnicodeCE::U_DT_MEDIAL
,
69 DecompositionNarrow
= UnicodeCE::U_DT_NARROW
,
70 DecompositionNoBreak
= UnicodeCE::U_DT_NOBREAK
,
71 DecompositionSmall
= UnicodeCE::U_DT_SMALL
,
72 DecompositionSquare
= UnicodeCE::U_DT_SQUARE
,
73 DecompositionSub
= UnicodeCE::U_DT_SUB
,
74 DecompositionSuper
= UnicodeCE::U_DT_SUPER
,
75 DecompositionVertical
= UnicodeCE::U_DT_VERTICAL
,
76 DecompositionWide
= UnicodeCE::U_DT_WIDE
81 Other_NotAssigned
= TO_MASK(UnicodeCE::U_GENERAL_OTHER_TYPES
),
82 Letter_Uppercase
= TO_MASK(UnicodeCE::U_UPPERCASE_LETTER
),
83 Letter_Lowercase
= TO_MASK(UnicodeCE::U_LOWERCASE_LETTER
),
84 Letter_Titlecase
= TO_MASK(UnicodeCE::U_TITLECASE_LETTER
),
85 Letter_Modifier
= TO_MASK(UnicodeCE::U_MODIFIER_LETTER
),
86 Letter_Other
= TO_MASK(UnicodeCE::U_OTHER_LETTER
),
88 Mark_NonSpacing
= TO_MASK(UnicodeCE::U_NON_SPACING_MARK
),
89 Mark_Enclosing
= TO_MASK(UnicodeCE::U_ENCLOSING_MARK
),
90 Mark_SpacingCombining
= TO_MASK(UnicodeCE::U_COMBINING_SPACING_MARK
),
92 Number_DecimalDigit
= TO_MASK(UnicodeCE::U_DECIMAL_DIGIT_NUMBER
),
93 Number_Letter
= TO_MASK(UnicodeCE::U_LETTER_NUMBER
),
94 Number_Other
= TO_MASK(UnicodeCE::U_OTHER_NUMBER
),
96 Separator_Space
= TO_MASK(UnicodeCE::U_SPACE_SEPARATOR
),
97 Separator_Line
= TO_MASK(UnicodeCE::U_LINE_SEPARATOR
),
98 Separator_Paragraph
= TO_MASK(UnicodeCE::U_PARAGRAPH_SEPARATOR
),
100 Other_Control
= TO_MASK(UnicodeCE::U_CONTROL_CHAR
),
101 Other_Format
= TO_MASK(UnicodeCE::U_FORMAT_CHAR
),
102 Other_PrivateUse
= TO_MASK(UnicodeCE::U_PRIVATE_USE_CHAR
),
103 Other_Surrogate
= TO_MASK(UnicodeCE::U_SURROGATE
),
105 Punctuation_Dash
= TO_MASK(UnicodeCE::U_DASH_PUNCTUATION
),
106 Punctuation_Open
= TO_MASK(UnicodeCE::U_START_PUNCTUATION
),
107 Punctuation_Close
= TO_MASK(UnicodeCE::U_END_PUNCTUATION
),
108 Punctuation_Connector
= TO_MASK(UnicodeCE::U_CONNECTOR_PUNCTUATION
),
109 Punctuation_Other
= TO_MASK(UnicodeCE::U_OTHER_PUNCTUATION
),
111 Symbol_Math
= TO_MASK(UnicodeCE::U_MATH_SYMBOL
),
112 Symbol_Currency
= TO_MASK(UnicodeCE::U_CURRENCY_SYMBOL
),
113 Symbol_Modifier
= TO_MASK(UnicodeCE::U_MODIFIER_SYMBOL
),
114 Symbol_Other
= TO_MASK(UnicodeCE::U_OTHER_SYMBOL
),
116 Punctuation_InitialQuote
= TO_MASK(UnicodeCE::U_INITIAL_PUNCTUATION
),
117 Punctuation_FinalQuote
= TO_MASK(UnicodeCE::U_FINAL_PUNCTUATION
)
120 CharCategory
category(unsigned int);
123 bool isLetter(UChar
);
124 bool isPrintableChar(UChar
);
129 bool isAlphanumeric(UChar
);
130 inline bool isSeparatorSpace(UChar c
) { return category(c
) == Separator_Space
; }
131 inline bool isHighSurrogate(UChar c
) { return (c
& 0xfc00) == 0xd800; }
132 inline bool isLowSurrogate(UChar c
) { return (c
& 0xfc00) == 0xdc00; }
134 UChar
toLower(UChar
);
135 UChar
toUpper(UChar
);
136 UChar
foldCase(UChar
);
137 UChar
toTitleCase(UChar
);
138 int toLower(UChar
* result
, int resultLength
, const UChar
* source
, int sourceLength
, bool* isError
);
139 int toUpper(UChar
* result
, int resultLength
, const UChar
* source
, int sourceLength
, bool* isError
);
140 int foldCase(UChar
* result
, int resultLength
, const UChar
* source
, int sourceLength
, bool* isError
);
142 int digitValue(UChar
);
144 UChar
mirroredChar(UChar32
);
145 unsigned char combiningClass(UChar32
);
146 DecompositionType
decompositionType(UChar32
);
147 Direction
direction(UChar32
);
148 inline bool isArabicChar(UChar32 c
)
150 return c
>= 0x0600 && c
<= 0x06FF;
153 inline bool hasLineBreakingPropertyComplexContext(UChar32
)
155 return false; // FIXME: implement!
158 inline int umemcasecmp(const UChar
* a
, const UChar
* b
, int len
)
160 for (int i
= 0; i
< len
; ++i
) {
161 UChar c1
= foldCase(a
[i
]);
162 UChar c2
= foldCase(b
[i
]);
169 inline UChar32
surrogateToUcs4(UChar high
, UChar low
)
171 return (UChar32(high
) << 10) + low
- 0x35fdc00;
174 } // namespace Unicode
177 #endif // WTF_UnicodeWinCE_h