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) 2008 Jürg Billeter <j@bitron.ch>
6 * Copyright (C) 2008 Dominik Röttsches <dominik.roettsches@access-company.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
28 #include "UnicodeMacrosFromICU.h"
29 #include <wtf/gtk/GOwnPtr.h>
32 #include <pango/pango.h>
37 typedef uint16_t UChar
;
38 typedef int32_t UChar32
;
47 EuropeanNumberSeparator
,
48 EuropeanNumberTerminator
,
50 CommonNumberSeparator
,
65 enum DecompositionType
{
67 DecompositionCanonical
,
72 DecompositionFraction
,
74 DecompositionIsolated
,
82 DecompositionVertical
,
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
),
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
),
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
),
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
),
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
),
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
),
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
),
123 Punctuation_InitialQuote
= U_MASK(G_UNICODE_INITIAL_PUNCTUATION
),
124 Punctuation_FinalQuote
= U_MASK(G_UNICODE_FINAL_PUNCTUATION
)
127 UChar32
foldCase(UChar32
);
129 int foldCase(UChar
* result
, int resultLength
, const UChar
* src
, int srcLength
, bool* error
);
131 int toLower(UChar
* result
, int resultLength
, const UChar
* src
, int srcLength
, bool* error
);
133 inline UChar32
toLower(UChar32 c
)
135 return g_unichar_tolower(c
);
138 inline UChar32
toUpper(UChar32 c
)
140 return g_unichar_toupper(c
);
143 int toUpper(UChar
* result
, int resultLength
, const UChar
* src
, int srcLength
, bool* error
);
145 inline UChar32
toTitleCase(UChar32 c
)
147 return g_unichar_totitle(c
);
150 inline bool isArabicChar(UChar32 c
)
152 return c
>= 0x0600 && c
<= 0x06FF;
155 inline bool isAlphanumeric(UChar32 c
)
157 return g_unichar_isalnum(c
);
160 inline bool isFormatChar(UChar32 c
)
162 return g_unichar_type(c
) == G_UNICODE_FORMAT
;
165 inline bool isSeparatorSpace(UChar32 c
)
167 return g_unichar_type(c
) == G_UNICODE_SPACE_SEPARATOR
;
170 inline bool isPrintableChar(UChar32 c
)
172 return g_unichar_isprint(c
);
175 inline bool isDigit(UChar32 c
)
177 return g_unichar_isdigit(c
);
180 inline bool isPunct(UChar32 c
)
182 return g_unichar_ispunct(c
);
185 inline bool hasLineBreakingPropertyComplexContext(UChar32 c
)
191 inline bool hasLineBreakingPropertyComplexContextOrIdeographic(UChar32 c
)
197 inline UChar32
mirroredChar(UChar32 c
)
200 g_unichar_get_mirror_char(c
, &mirror
);
204 inline CharCategory
category(UChar32 c
)
209 return (CharCategory
) U_MASK(g_unichar_type(c
));
212 Direction
direction(UChar32
);
214 inline bool isLower(UChar32 c
)
216 return g_unichar_islower(c
);
219 inline int digitValue(UChar32 c
)
221 return g_unichar_digit_value(c
);
224 inline uint8_t combiningClass(UChar32 c
)
227 // return g_unichar_combining_class(c);
231 inline DecompositionType
decompositionType(UChar32 c
)
234 return DecompositionNone
;
237 int umemcasecmp(const UChar
*, const UChar
*, int len
);