| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
> |
| 6 |
> |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
#ifndef UnicodeGLib_h |
| 26 |
#define UnicodeGLib_h |
| 27 |
|
| 28 |
#include "UnicodeMacrosFromICU.h" |
| 29 |
#include <wtf/gtk/GOwnPtr.h> |
| 30 |
|
| 31 |
#include <glib.h> |
| 32 |
#include <pango/pango.h> |
| 33 |
#include <stdint.h> |
| 34 |
#include <stdlib.h> |
| 35 |
#include <string.h> |
| 36 |
|
| 37 |
typedef uint16_t UChar; |
| 38 |
typedef int32_t UChar32; |
| 39 |
|
| 40 |
namespace WTF { |
| 41 |
namespace Unicode { |
| 42 |
|
| 43 |
enum Direction { |
| 44 |
LeftToRight, |
| 45 |
RightToLeft, |
| 46 |
EuropeanNumber, |
| 47 |
EuropeanNumberSeparator, |
| 48 |
EuropeanNumberTerminator, |
| 49 |
ArabicNumber, |
| 50 |
CommonNumberSeparator, |
| 51 |
BlockSeparator, |
| 52 |
SegmentSeparator, |
| 53 |
WhiteSpaceNeutral, |
| 54 |
OtherNeutral, |
| 55 |
LeftToRightEmbedding, |
| 56 |
LeftToRightOverride, |
| 57 |
RightToLeftArabic, |
| 58 |
RightToLeftEmbedding, |
| 59 |
RightToLeftOverride, |
| 60 |
PopDirectionalFormat, |
| 61 |
NonSpacingMark, |
| 62 |
BoundaryNeutral |
| 63 |
}; |
| 64 |
|
| 65 |
enum DecompositionType { |
| 66 |
DecompositionNone, |
| 67 |
DecompositionCanonical, |
| 68 |
DecompositionCompat, |
| 69 |
DecompositionCircle, |
| 70 |
DecompositionFinal, |
| 71 |
DecompositionFont, |
| 72 |
DecompositionFraction, |
| 73 |
DecompositionInitial, |
| 74 |
DecompositionIsolated, |
| 75 |
DecompositionMedial, |
| 76 |
DecompositionNarrow, |
| 77 |
DecompositionNoBreak, |
| 78 |
DecompositionSmall, |
| 79 |
DecompositionSquare, |
| 80 |
DecompositionSub, |
| 81 |
DecompositionSuper, |
| 82 |
DecompositionVertical, |
| 83 |
DecompositionWide, |
| 84 |
}; |
| 85 |
|
| 86 |
enum CharCategory { |
| 87 |
NoCategory = 0, |
| 88 |
Other_NotAssigned = U_MASK(G_UNICODE_UNASSIGNED), |
| 89 |
Letter_Uppercase = U_MASK(G_UNICODE_UPPERCASE_LETTER), |
| 90 |
Letter_Lowercase = U_MASK(G_UNICODE_LOWERCASE_LETTER), |
| 91 |
Letter_Titlecase = U_MASK(G_UNICODE_TITLECASE_LETTER), |
| 92 |
Letter_Modifier = U_MASK(G_UNICODE_MODIFIER_LETTER), |
| 93 |
Letter_Other = U_MASK(G_UNICODE_OTHER_LETTER), |
| 94 |
|
| 95 |
Mark_NonSpacing = U_MASK(G_UNICODE_NON_SPACING_MARK), |
| 96 |
Mark_Enclosing = U_MASK(G_UNICODE_ENCLOSING_MARK), |
| 97 |
Mark_SpacingCombining = U_MASK(G_UNICODE_COMBINING_MARK), |
| 98 |
|
| 99 |
Number_DecimalDigit = U_MASK(G_UNICODE_DECIMAL_NUMBER), |
| 100 |
Number_Letter = U_MASK(G_UNICODE_LETTER_NUMBER), |
| 101 |
Number_Other = U_MASK(G_UNICODE_OTHER_NUMBER), |
| 102 |
|
| 103 |
Separator_Space = U_MASK(G_UNICODE_SPACE_SEPARATOR), |
| 104 |
Separator_Line = U_MASK(G_UNICODE_LINE_SEPARATOR), |
| 105 |
Separator_Paragraph = U_MASK(G_UNICODE_PARAGRAPH_SEPARATOR), |
| 106 |
|
| 107 |
Other_Control = U_MASK(G_UNICODE_CONTROL), |
| 108 |
Other_Format = U_MASK(G_UNICODE_FORMAT), |
| 109 |
Other_PrivateUse = U_MASK(G_UNICODE_PRIVATE_USE), |
| 110 |
Other_Surrogate = U_MASK(G_UNICODE_SURROGATE), |
| 111 |
|
| 112 |
Punctuation_Dash = U_MASK(G_UNICODE_DASH_PUNCTUATION), |
| 113 |
Punctuation_Open = U_MASK(G_UNICODE_OPEN_PUNCTUATION), |
| 114 |
Punctuation_Close = U_MASK(G_UNICODE_CLOSE_PUNCTUATION), |
| 115 |
Punctuation_Connector = U_MASK(G_UNICODE_CONNECT_PUNCTUATION), |
| 116 |
Punctuation_Other = U_MASK(G_UNICODE_OTHER_PUNCTUATION), |
| 117 |
|
| 118 |
Symbol_Math = U_MASK(G_UNICODE_MATH_SYMBOL), |
| 119 |
Symbol_Currency = U_MASK(G_UNICODE_CURRENCY_SYMBOL), |
| 120 |
Symbol_Modifier = U_MASK(G_UNICODE_MODIFIER_SYMBOL), |
| 121 |
Symbol_Other = U_MASK(G_UNICODE_OTHER_SYMBOL), |
| 122 |
|
| 123 |
Punctuation_InitialQuote = U_MASK(G_UNICODE_INITIAL_PUNCTUATION), |
| 124 |
Punctuation_FinalQuote = U_MASK(G_UNICODE_FINAL_PUNCTUATION) |
| 125 |
}; |
| 126 |
|
| 127 |
UChar32 foldCase(UChar32); |
| 128 |
|
| 129 |
int foldCase(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error); |
| 130 |
|
| 131 |
int toLower(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error); |
| 132 |
|
| 133 |
inline UChar32 toLower(UChar32 c) |
| 134 |
{ |
| 135 |
return g_unichar_tolower(c); |
| 136 |
} |
| 137 |
|
| 138 |
inline UChar32 toUpper(UChar32 c) |
| 139 |
{ |
| 140 |
return g_unichar_toupper(c); |
| 141 |
} |
| 142 |
|
| 143 |
int toUpper(UChar* result, int resultLength, const UChar* src, int srcLength, bool* error); |
| 144 |
|
| 145 |
inline UChar32 toTitleCase(UChar32 c) |
| 146 |
{ |
| 147 |
return g_unichar_totitle(c); |
| 148 |
} |
| 149 |
|
| 150 |
inline bool isArabicChar(UChar32 c) |
| 151 |
{ |
| 152 |
return c >= 0x0600 && c <= 0x06FF; |
| 153 |
} |
| 154 |
|
| 155 |
inline bool isAlphanumeric(UChar32 c) |
| 156 |
{ |
| 157 |
return g_unichar_isalnum(c); |
| 158 |
} |
| 159 |
|
| 160 |
inline bool isFormatChar(UChar32 c) |
| 161 |
{ |
| 162 |
return g_unichar_type(c) == G_UNICODE_FORMAT; |
| 163 |
} |
| 164 |
|
| 165 |
inline bool isSeparatorSpace(UChar32 c) |
| 166 |
{ |
| 167 |
return g_unichar_type(c) == G_UNICODE_SPACE_SEPARATOR; |
| 168 |
} |
| 169 |
|
| 170 |
inline bool isPrintableChar(UChar32 c) |
| 171 |
{ |
| 172 |
return g_unichar_isprint(c); |
| 173 |
} |
| 174 |
|
| 175 |
inline bool isDigit(UChar32 c) |
| 176 |
{ |
| 177 |
return g_unichar_isdigit(c); |
| 178 |
} |
| 179 |
|
| 180 |
inline bool isPunct(UChar32 c) |
| 181 |
{ |
| 182 |
return g_unichar_ispunct(c); |
| 183 |
} |
| 184 |
|
| 185 |
inline bool hasLineBreakingPropertyComplexContext(UChar32 c) |
| 186 |
{ |
| 187 |
|
| 188 |
return false; |
| 189 |
} |
| 190 |
|
| 191 |
inline bool hasLineBreakingPropertyComplexContextOrIdeographic(UChar32 c) |
| 192 |
{ |
| 193 |
|
| 194 |
return false; |
| 195 |
} |
| 196 |
|
| 197 |
inline UChar32 mirroredChar(UChar32 c) |
| 198 |
{ |
| 199 |
gunichar mirror = 0; |
| 200 |
g_unichar_get_mirror_char(c, &mirror); |
| 201 |
return mirror; |
| 202 |
} |
| 203 |
|
| 204 |
inline CharCategory category(UChar32 c) |
| 205 |
{ |
| 206 |
if (c > 0xffff) |
| 207 |
return NoCategory; |
| 208 |
|
| 209 |
return (CharCategory) U_MASK(g_unichar_type(c)); |
| 210 |
} |
| 211 |
|
| 212 |
Direction direction(UChar32); |
| 213 |
|
| 214 |
inline bool isLower(UChar32 c) |
| 215 |
{ |
| 216 |
return g_unichar_islower(c); |
| 217 |
} |
| 218 |
|
| 219 |
inline int digitValue(UChar32 c) |
| 220 |
{ |
| 221 |
return g_unichar_digit_value(c); |
| 222 |
} |
| 223 |
|
| 224 |
inline uint8_t combiningClass(UChar32 c) |
| 225 |
{ |
| 226 |
|
| 227 |
|
| 228 |
return 0; |
| 229 |
} |
| 230 |
|
| 231 |
inline DecompositionType decompositionType(UChar32 c) |
| 232 |
{ |
| 233 |
|
| 234 |
return DecompositionNone; |
| 235 |
} |
| 236 |
|
| 237 |
int umemcasecmp(const UChar*, const UChar*, int len); |
| 238 |
|
| 239 |
} |
| 240 |
} |
| 241 |
|
| 242 |
#endif |
| 243 |
|