| 1 |
. |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef __UCASE_H__ |
| 22 |
#define __UCASE_H__ |
| 23 |
|
| 24 |
#include "unicode/utypes.h" |
| 25 |
#include "unicode/uset.h" |
| 26 |
#include "putilimp.h" |
| 27 |
#include "uset_imp.h" |
| 28 |
#include "udataswp.h" |
| 29 |
#include "utrie2.h" |
| 30 |
|
| 31 |
#ifdef __cplusplus |
| 32 |
U_NAMESPACE_BEGIN |
| 33 |
|
| 34 |
class UnicodeString; |
| 35 |
|
| 36 |
U_NAMESPACE_END |
| 37 |
#endif |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
U_CFUNC void U_EXPORT2 |
| 42 |
ucase_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode); |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
U_CFUNC int32_t |
| 50 |
ucase_getCaseLocale(const char *locale); |
| 51 |
|
| 52 |
|
| 53 |
enum { |
| 54 |
UCASE_LOC_UNKNOWN, |
| 55 |
UCASE_LOC_ROOT, |
| 56 |
UCASE_LOC_TURKISH, |
| 57 |
UCASE_LOC_LITHUANIAN, |
| 58 |
UCASE_LOC_GREEK, |
| 59 |
UCASE_LOC_DUTCH, |
| 60 |
UCASE_LOC_ARMENIAN |
| 61 |
}; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
#define _STRCASECMP_OPTIONS_MASK 0xffff |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
#define _FOLD_CASE_OPTIONS_MASK 7 |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
U_CAPI UChar32 U_EXPORT2 |
| 88 |
ucase_tolower(UChar32 c); |
| 89 |
|
| 90 |
U_CAPI UChar32 U_EXPORT2 |
| 91 |
ucase_toupper(UChar32 c); |
| 92 |
|
| 93 |
U_CAPI UChar32 U_EXPORT2 |
| 94 |
ucase_totitle(UChar32 c); |
| 95 |
|
| 96 |
U_CAPI UChar32 U_EXPORT2 |
| 97 |
ucase_fold(UChar32 c, uint32_t options); |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
U_CFUNC void U_EXPORT2 |
| 109 |
ucase_addCaseClosure(UChar32 c, const USetAdder *sa); |
| 110 |
|
| 111 |
|
| 112 |
U_CFUNC void U_EXPORT2 |
| 113 |
ucase_addSimpleCaseClosure(UChar32 c, const USetAdder *sa); |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
U_CFUNC UBool U_EXPORT2 |
| 128 |
ucase_addStringCaseClosure(const UChar *s, int32_t length, const USetAdder *sa); |
| 129 |
|
| 130 |
#ifdef __cplusplus |
| 131 |
U_NAMESPACE_BEGIN |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
class U_COMMON_API FullCaseFoldingIterator { |
| 137 |
public: |
| 138 |
|
| 139 |
FullCaseFoldingIterator(); |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
UChar32 next(UnicodeString &full); |
| 145 |
private: |
| 146 |
FullCaseFoldingIterator(const FullCaseFoldingIterator &) = delete; |
| 147 |
FullCaseFoldingIterator &operator=(const FullCaseFoldingIterator &) = delete; |
| 148 |
|
| 149 |
const char16_t *unfold; |
| 150 |
int32_t unfoldRows; |
| 151 |
int32_t unfoldRowWidth; |
| 152 |
int32_t unfoldStringWidth; |
| 153 |
int32_t currentRow; |
| 154 |
int32_t rowCpIndex; |
| 155 |
}; |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
namespace LatinCase { |
| 164 |
|
| 165 |
|
| 166 |
constexpr char16_t LIMIT = 0x180; |
| 167 |
|
| 168 |
constexpr char16_t LONG_S = 0x17f; |
| 169 |
|
| 170 |
constexpr int8_t EXC = -0x80; |
| 171 |
|
| 172 |
|
| 173 |
extern const int8_t TO_LOWER_NORMAL[LIMIT]; |
| 174 |
|
| 175 |
extern const int8_t TO_LOWER_TR_LT[LIMIT]; |
| 176 |
|
| 177 |
|
| 178 |
extern const int8_t TO_UPPER_NORMAL[LIMIT]; |
| 179 |
|
| 180 |
extern const int8_t TO_UPPER_TR[LIMIT]; |
| 181 |
|
| 182 |
} |
| 183 |
|
| 184 |
U_NAMESPACE_END |
| 185 |
#endif |
| 186 |
|
| 187 |
|
| 188 |
U_CAPI int32_t U_EXPORT2 |
| 189 |
ucase_getType(UChar32 c); |
| 190 |
|
| 191 |
|
| 192 |
U_CAPI int32_t U_EXPORT2 |
| 193 |
ucase_getTypeOrIgnorable(UChar32 c); |
| 194 |
|
| 195 |
U_CAPI UBool U_EXPORT2 |
| 196 |
ucase_isSoftDotted(UChar32 c); |
| 197 |
|
| 198 |
U_CAPI UBool U_EXPORT2 |
| 199 |
ucase_isCaseSensitive(UChar32 c); |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
U_CDECL_BEGIN |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
typedef UChar32 U_CALLCONV |
| 224 |
UCaseContextIterator(void *context, int8_t dir); |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
struct UCaseContext { |
| 231 |
void *p; |
| 232 |
int32_t start, index, limit; |
| 233 |
int32_t cpStart, cpLimit; |
| 234 |
int8_t dir; |
| 235 |
int8_t b1, b2, b3; |
| 236 |
}; |
| 237 |
typedef struct UCaseContext UCaseContext; |
| 238 |
|
| 239 |
U_CDECL_END |
| 240 |
|
| 241 |
#define UCASECONTEXT_INITIALIZER { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0 } |
| 242 |
|
| 243 |
enum { |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
UCASE_MAX_STRING_LENGTH=0x1f |
| 259 |
}; |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
U_CAPI int32_t U_EXPORT2 |
| 280 |
ucase_toFullLower(UChar32 c, |
| 281 |
UCaseContextIterator *iter, void *context, |
| 282 |
const UChar **pString, |
| 283 |
int32_t caseLocale); |
| 284 |
|
| 285 |
U_CAPI int32_t U_EXPORT2 |
| 286 |
ucase_toFullUpper(UChar32 c, |
| 287 |
UCaseContextIterator *iter, void *context, |
| 288 |
const UChar **pString, |
| 289 |
int32_t caseLocale); |
| 290 |
|
| 291 |
U_CAPI int32_t U_EXPORT2 |
| 292 |
ucase_toFullTitle(UChar32 c, |
| 293 |
UCaseContextIterator *iter, void *context, |
| 294 |
const UChar **pString, |
| 295 |
int32_t caseLocale); |
| 296 |
|
| 297 |
U_CAPI int32_t U_EXPORT2 |
| 298 |
ucase_toFullFolding(UChar32 c, |
| 299 |
const UChar **pString, |
| 300 |
uint32_t options); |
| 301 |
|
| 302 |
U_CFUNC int32_t U_EXPORT2 |
| 303 |
ucase_hasBinaryProperty(UChar32 c, UProperty which); |
| 304 |
|
| 305 |
|
| 306 |
U_CDECL_BEGIN |
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
typedef int32_t U_CALLCONV |
| 312 |
UCaseMapFull(UChar32 c, |
| 313 |
UCaseContextIterator *iter, void *context, |
| 314 |
const UChar **pString, |
| 315 |
int32_t caseLocale); |
| 316 |
|
| 317 |
U_CDECL_END |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
struct UCaseProps { |
| 322 |
void *mem; |
| 323 |
const int32_t *indexes; |
| 324 |
const uint16_t *exceptions; |
| 325 |
const uint16_t *unfold; |
| 326 |
|
| 327 |
UTrie2 trie; |
| 328 |
uint8_t formatVersion[4]; |
| 329 |
}; |
| 330 |
|
| 331 |
U_CAPI const struct UCaseProps * U_EXPORT2 |
| 332 |
ucase_getSingleton(int32_t *pExceptionsLength, int32_t *pUnfoldLength); |
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
#define UCASE_DATA_NAME "ucase" |
| 337 |
#define UCASE_DATA_TYPE "icu" |
| 338 |
|
| 339 |
|
| 340 |
#define UCASE_FMT_0 0x63 |
| 341 |
#define UCASE_FMT_1 0x41 |
| 342 |
#define UCASE_FMT_2 0x53 |
| 343 |
#define UCASE_FMT_3 0x45 |
| 344 |
|
| 345 |
|
| 346 |
enum { |
| 347 |
UCASE_IX_INDEX_TOP, |
| 348 |
UCASE_IX_LENGTH, |
| 349 |
UCASE_IX_TRIE_SIZE, |
| 350 |
UCASE_IX_EXC_LENGTH, |
| 351 |
UCASE_IX_UNFOLD_LENGTH, |
| 352 |
|
| 353 |
UCASE_IX_MAX_FULL_LENGTH=15, |
| 354 |
UCASE_IX_TOP=16 |
| 355 |
}; |
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
U_CFUNC const UTrie2 * U_EXPORT2 |
| 360 |
ucase_getTrie(void); |
| 361 |
|
| 362 |
|
| 363 |
#define UCASE_TYPE_MASK 3 |
| 364 |
enum { |
| 365 |
UCASE_NONE, |
| 366 |
UCASE_LOWER, |
| 367 |
UCASE_UPPER, |
| 368 |
UCASE_TITLE |
| 369 |
}; |
| 370 |
|
| 371 |
#define UCASE_GET_TYPE(props) ((props)&UCASE_TYPE_MASK) |
| 372 |
#define UCASE_GET_TYPE_AND_IGNORABLE(props) ((props)&7) |
| 373 |
|
| 374 |
#define UCASE_IS_UPPER_OR_TITLE(props) ((props)&2) |
| 375 |
|
| 376 |
#define UCASE_IGNORABLE 4 |
| 377 |
#define UCASE_EXCEPTION 8 |
| 378 |
#define UCASE_SENSITIVE 0x10 |
| 379 |
|
| 380 |
#define UCASE_HAS_EXCEPTION(props) ((props)&UCASE_EXCEPTION) |
| 381 |
|
| 382 |
#define UCASE_DOT_MASK 0x60 |
| 383 |
enum { |
| 384 |
UCASE_NO_DOT=0, |
| 385 |
UCASE_SOFT_DOTTED=0x20, |
| 386 |
UCASE_ABOVE=0x40, |
| 387 |
UCASE_OTHER_ACCENT=0x60 |
| 388 |
}; |
| 389 |
|
| 390 |
|
| 391 |
#define UCASE_DELTA_SHIFT 7 |
| 392 |
#define UCASE_DELTA_MASK 0xff80 |
| 393 |
#define UCASE_MAX_DELTA 0xff |
| 394 |
#define UCASE_MIN_DELTA (-UCASE_MAX_DELTA-1) |
| 395 |
|
| 396 |
#if U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC |
| 397 |
# define UCASE_GET_DELTA(props) ((int16_t)(props)>>UCASE_DELTA_SHIFT) |
| 398 |
#else |
| 399 |
# define UCASE_GET_DELTA(props) (int16_t)(((props)&0x8000) ? (((props)>>UCASE_DELTA_SHIFT)|0xfe00) : ((uint16_t)(props)>>UCASE_DELTA_SHIFT)) |
| 400 |
#endif |
| 401 |
|
| 402 |
|
| 403 |
#define UCASE_EXC_SHIFT 4 |
| 404 |
#define UCASE_EXC_MASK 0xfff0 |
| 405 |
#define UCASE_MAX_EXCEPTIONS ((UCASE_EXC_MASK>>UCASE_EXC_SHIFT)+1) |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
enum { |
| 411 |
UCASE_EXC_LOWER, |
| 412 |
UCASE_EXC_FOLD, |
| 413 |
UCASE_EXC_UPPER, |
| 414 |
UCASE_EXC_TITLE, |
| 415 |
UCASE_EXC_DELTA, |
| 416 |
UCASE_EXC_5, |
| 417 |
UCASE_EXC_CLOSURE, |
| 418 |
UCASE_EXC_FULL_MAPPINGS, |
| 419 |
UCASE_EXC_ALL_SLOTS |
| 420 |
}; |
| 421 |
|
| 422 |
|
| 423 |
#define UCASE_EXC_DOUBLE_SLOTS 0x100 |
| 424 |
|
| 425 |
enum { |
| 426 |
UCASE_EXC_NO_SIMPLE_CASE_FOLDING=0x200, |
| 427 |
UCASE_EXC_DELTA_IS_NEGATIVE=0x400, |
| 428 |
UCASE_EXC_SENSITIVE=0x800 |
| 429 |
}; |
| 430 |
|
| 431 |
|
| 432 |
#define UCASE_EXC_DOT_SHIFT 7 |
| 433 |
|
| 434 |
|
| 435 |
#define UCASE_EXC_DOT_MASK 0x3000 |
| 436 |
enum { |
| 437 |
UCASE_EXC_NO_DOT=0, |
| 438 |
UCASE_EXC_SOFT_DOTTED=0x1000, |
| 439 |
UCASE_EXC_ABOVE=0x2000, |
| 440 |
UCASE_EXC_OTHER_ACCENT=0x3000 |
| 441 |
}; |
| 442 |
|
| 443 |
|
| 444 |
#define UCASE_EXC_CONDITIONAL_SPECIAL 0x4000 |
| 445 |
#define UCASE_EXC_CONDITIONAL_FOLD 0x8000 |
| 446 |
|
| 447 |
|
| 448 |
#define UCASE_FULL_LOWER 0xf |
| 449 |
#define UCASE_FULL_FOLDING 0xf0 |
| 450 |
#define UCASE_FULL_UPPER 0xf00 |
| 451 |
#define UCASE_FULL_TITLE 0xf000 |
| 452 |
|
| 453 |
|
| 454 |
#define UCASE_FULL_MAPPINGS_MAX_LENGTH (4*0xf) |
| 455 |
#define UCASE_CLOSURE_MAX_LENGTH 0xf |
| 456 |
|
| 457 |
|
| 458 |
enum { |
| 459 |
UCASE_UNFOLD_ROWS, |
| 460 |
UCASE_UNFOLD_ROW_WIDTH, |
| 461 |
UCASE_UNFOLD_STRING_WIDTH |
| 462 |
}; |
| 463 |
|
| 464 |
#endif |