1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* 2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru******************************************************************************* 3b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius* Copyright (C) 2004-2012, International Business Machines 5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Corporation and others. All Rights Reserved. 6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru******************************************************************************* 8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* file name: ucase.h 9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* encoding: US-ASCII 10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* tab size: 8 (not used) 11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* indentation:4 12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* created on: 2004aug30 14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* created by: Markus W. Scherer 15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Low-level Unicode character/string case mapping code. 17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/ 18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef __UCASE_H__ 20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define __UCASE_H__ 21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h" 23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/uset.h" 2483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#include "putilimp.h" 25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uset_imp.h" 26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "udataswp.h" 27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#ifdef __cplusplus 2983a171d1a62abf406f7f44ae671823d5ec20db7dCraig CorneliusU_NAMESPACE_BEGIN 3083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius 3183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Corneliusclass UnicodeString; 3283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius 3383a171d1a62abf406f7f44ae671823d5ec20db7dCraig CorneliusU_NAMESPACE_END 3483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#endif 35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* library API -------------------------------------------------------------- */ 37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3883a171d1a62abf406f7f44ae671823d5ec20db7dCraig CorneliusU_CDECL_BEGIN 3983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius 40b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustruct UCaseProps; 41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef struct UCaseProps UCaseProps; 42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 4383a171d1a62abf406f7f44ae671823d5ec20db7dCraig CorneliusU_CDECL_END 4483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius 45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI const UCaseProps * U_EXPORT2 4627f654740f2a26ad62a5c155af9199af9e69b889clairehoucase_getSingleton(void); 47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CFUNC void U_EXPORT2 49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_addPropertyStarts(const UCaseProps *csp, const USetAdder *sa, UErrorCode *pErrorCode); 50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Requires non-NULL locale ID but otherwise does the equivalent of 53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * checking for language codes as if uloc_getLanguage() were called: 54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Accepts both 2- and 3-letter codes and accepts case variants. 55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CFUNC int32_t 57b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_getCaseLocale(const char *locale, int32_t *locCache); 58b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 59c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru/* Casing locale types for ucase_getCaseLocale */ 60c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queruenum { 61c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru UCASE_LOC_UNKNOWN, 62c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru UCASE_LOC_ROOT, 63c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru UCASE_LOC_TURKISH, 64c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru UCASE_LOC_LITHUANIAN, 65c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru UCASE_LOC_DUTCH 66c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru}; 67c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru 68b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Bit mask for getting just the options from a string compare options word 70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that are relevant for case-insensitive string comparison. 71b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * See uchar.h. Also include _STRNCMP_STYLE and U_COMPARE_CODE_POINT_ORDER. 72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 73b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 74b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define _STRCASECMP_OPTIONS_MASK 0xffff 75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 76b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 77b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Bit mask for getting just the options from a string compare options word 78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * that are relevant for case folding (of a single string or code point). 79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * See uchar.h. 80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define _FOLD_CASE_OPTIONS_MASK 0xff 83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* single-code point functions */ 85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UChar32 U_EXPORT2 87b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_tolower(const UCaseProps *csp, UChar32 c); 88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 89b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UChar32 U_EXPORT2 90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_toupper(const UCaseProps *csp, UChar32 c); 91b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 92b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UChar32 U_EXPORT2 93b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_totitle(const UCaseProps *csp, UChar32 c); 94b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UChar32 U_EXPORT2 96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_fold(const UCaseProps *csp, UChar32 c, uint32_t options); 97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Adds all simple case mappings and the full case folding for c to sa, 100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and also adds special case closure mappings. 101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * c itself is not added. 102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For example, the mappings 103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - for s include long s 104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - for sharp s include ss 105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - for k include the Kelvin sign 106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CFUNC void U_EXPORT2 108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_addCaseClosure(const UCaseProps *csp, UChar32 c, const USetAdder *sa); 109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Maps the string to single code points and adds the associated case closure 112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * mappings. 113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The string is mapped to code points if it is their full case folding string. 114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * In other words, this performs a reverse full case folding and then 115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * adds the case closure items of the resulting code points. 116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If the string is found and its closure applied, then 117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the string itself is added as well as part of its code points' closure. 118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It must be length>=0. 119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return TRUE if the string was found 121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CFUNC UBool U_EXPORT2 123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_addStringCaseClosure(const UCaseProps *csp, const UChar *s, int32_t length, const USetAdder *sa); 124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 12583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#ifdef __cplusplus 12683a171d1a62abf406f7f44ae671823d5ec20db7dCraig CorneliusU_NAMESPACE_BEGIN 12783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius 12883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius/** 12983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * Iterator over characters with more than one code point in the full default Case_Folding. 13083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius */ 13183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Corneliusclass U_COMMON_API FullCaseFoldingIterator { 13283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Corneliuspublic: 13383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius /** Constructor. */ 13483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius FullCaseFoldingIterator(); 13583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius /** 13683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * Returns the next (cp, full) pair where "full" is cp's full default Case_Folding. 13783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * Returns a negative cp value at the end of the iteration. 13883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius */ 13983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius UChar32 next(UnicodeString &full); 14083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Corneliusprivate: 14183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius FullCaseFoldingIterator(const FullCaseFoldingIterator &); // no copy 14283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius FullCaseFoldingIterator &operator=(const FullCaseFoldingIterator &); // no assignment 14383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius 14483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius const UChar *unfold; 14583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius int32_t unfoldRows; 14683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius int32_t unfoldRowWidth; 14783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius int32_t unfoldStringWidth; 14883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius int32_t currentRow; 14983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius int32_t rowCpIndex; 15083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius}; 15183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius 15283a171d1a62abf406f7f44ae671823d5ec20db7dCraig CorneliusU_NAMESPACE_END 15383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#endif 15483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius 155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** @return UCASE_NONE, UCASE_LOWER, UCASE_UPPER, UCASE_TITLE */ 156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_getType(const UCaseProps *csp, UChar32 c); 158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** @return same as ucase_getType(), or <0 if c is case-ignorable */ 160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_getTypeOrIgnorable(const UCaseProps *csp, UChar32 c); 162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UBool U_EXPORT2 164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_isSoftDotted(const UCaseProps *csp, UChar32 c); 165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI UBool U_EXPORT2 167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_isCaseSensitive(const UCaseProps *csp, UChar32 c); 168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* string case mapping functions */ 170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 17183a171d1a62abf406f7f44ae671823d5ec20db7dCraig CorneliusU_CDECL_BEGIN 17283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius 173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Iterator function for string case mappings, which need to look at the 175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * context (surrounding text) of a given character for conditional mappings. 176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The iterator only needs to go backward or forward away from the 178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * character in question. It does not use any indexes on this interface. 179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It does not support random access or an arbitrary change of 180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * iteration direction. 181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * The code point being case-mapped itself is never returned by 183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * this iterator. 184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param context A pointer to the iterator's working data. 186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dir If <0 then start iterating backward from the character; 187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if >0 then start iterating forward from the character; 188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * if 0 then continue iterating in the current direction. 189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Next code point, or <0 when the iteration is done. 190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef UChar32 U_CALLCONV 192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUCaseContextIterator(void *context, int8_t dir); 193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Sample struct which may be used by some implementations of 196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * UCaseContextIterator. 197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustruct UCaseContext { 199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru void *p; 200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t start, index, limit; 201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t cpStart, cpLimit; 202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int8_t dir; 203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int8_t b1, b2, b3; 204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef struct UCaseContext UCaseContext; 206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 20783a171d1a62abf406f7f44ae671823d5ec20db7dCraig CorneliusU_CDECL_END 20883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius 20983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASECONTEXT_INITIALIZER { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0 } 21083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius 211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum { 212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru /** 213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * For string case mappings, a single character (a code point) is mapped 214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * either to itself (in which case in-place mapping functions do nothing), 215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * or to another single code point, or to a string. 216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Aside from the string contents, these are indicated with a single int32_t 217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * value as follows: 218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Mapping to self: Negative values (~self instead of -self to support U+0000) 220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Mapping to another code point: Positive values >UCASE_MAX_STRING_LENGTH 222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Mapping to a string: The string length (0..UCASE_MAX_STRING_LENGTH) is 224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * returned. Note that the string result may indeed have zero length. 225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_MAX_STRING_LENGTH=0x1f 227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Get the full lowercase mapping for c. 231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param csp Case mapping properties. 233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param c Character to be mapped. 234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param iter Character iterator, used for context-sensitive mappings. 235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * See UCaseContextIterator for details. 236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If iter==NULL then a context-independent result is returned. 237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param context Pointer to be passed into iter. 238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param pString If the mapping result is a string, then the pointer is 239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * written to *pString. 240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param locale Locale ID for locale-dependent mappings. 241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param locCache Initialize to 0; may be used to cache the result of parsing 242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the locale ID for subsequent calls. 243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Can be NULL. 244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return Output code point or string length, see UCASE_MAX_STRING_LENGTH. 245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UCaseContextIterator 247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @see UCASE_MAX_STRING_LENGTH 248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_toFullLower(const UCaseProps *csp, UChar32 c, 252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCaseContextIterator *iter, void *context, 253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar **pString, 254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const char *locale, int32_t *locCache); 255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_toFullUpper(const UCaseProps *csp, UChar32 c, 258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCaseContextIterator *iter, void *context, 259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar **pString, 260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const char *locale, int32_t *locCache); 261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_toFullTitle(const UCaseProps *csp, UChar32 c, 264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCaseContextIterator *iter, void *context, 265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar **pString, 266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const char *locale, int32_t *locCache); 267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_toFullFolding(const UCaseProps *csp, UChar32 c, 270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar **pString, 271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options); 272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CFUNC int32_t U_EXPORT2 274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruucase_hasBinaryProperty(UChar32 c, UProperty which); 275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CDECL_BEGIN 278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef int32_t U_CALLCONV 283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUCaseMapFull(const UCaseProps *csp, UChar32 c, 284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCaseContextIterator *iter, void *context, 285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar **pString, 286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const char *locale, int32_t *locCache); 287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CDECL_END 289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* file definitions --------------------------------------------------------- */ 291b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 292b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_DATA_NAME "ucase" 293b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_DATA_TYPE "icu" 294b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 295b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* format "cAsE" */ 296b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_FMT_0 0x63 297b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_FMT_1 0x41 298b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_FMT_2 0x53 299b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_FMT_3 0x45 300b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 301b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* indexes into indexes[] */ 302b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum { 303b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_IX_INDEX_TOP, 304b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_IX_LENGTH, 305b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_IX_TRIE_SIZE, 306b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_IX_EXC_LENGTH, 307b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_IX_UNFOLD_LENGTH, 308b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 309b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_IX_MAX_FULL_LENGTH=15, 310b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_IX_TOP=16 311b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 312b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 313b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* definitions for 16-bit case properties word ------------------------------ */ 314b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 315b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* 2-bit constants for types of cased characters */ 316b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_TYPE_MASK 3 317b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum { 318b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_NONE, 319b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_LOWER, 320b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_UPPER, 321b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_TITLE 322b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 323b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 324b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_GET_TYPE(props) ((props)&UCASE_TYPE_MASK) 32583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_GET_TYPE_AND_IGNORABLE(props) ((props)&7) 326b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 32783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_IGNORABLE 4 32883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_SENSITIVE 8 32983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_EXCEPTION 0x10 330b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 33183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_DOT_MASK 0x60 332b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum { 333b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_NO_DOT=0, /* normal characters with cc=0 */ 33483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius UCASE_SOFT_DOTTED=0x20, /* soft-dotted characters with cc=0 */ 33583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius UCASE_ABOVE=0x40, /* "above" accents with cc=230 */ 33683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius UCASE_OTHER_ACCENT=0x60 /* other accent character (0<cc!=230) */ 337b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 338b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 33983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius/* no exception: bits 15..7 are a 9-bit signed case mapping delta */ 34083a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_DELTA_SHIFT 7 34183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_DELTA_MASK 0xff80 34283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_MAX_DELTA 0xff 343b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_MIN_DELTA (-UCASE_MAX_DELTA-1) 344b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 34583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#if U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC 34683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius# define UCASE_GET_DELTA(props) ((int16_t)(props)>>UCASE_DELTA_SHIFT) 34783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#else 34883a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius# define UCASE_GET_DELTA(props) (int16_t)(((props)&0x8000) ? (((props)>>UCASE_DELTA_SHIFT)|0xfe00) : ((uint16_t)(props)>>UCASE_DELTA_SHIFT)) 34983a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#endif 350b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 35183a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius/* exception: bits 15..5 are an unsigned 11-bit index into the exceptions array */ 35283a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_EXC_SHIFT 5 35383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_EXC_MASK 0xffe0 35483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_MAX_EXCEPTIONS ((UCASE_EXC_MASK>>UCASE_EXC_SHIFT)+1) 355b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 356b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* definitions for 16-bit main exceptions word ------------------------------ */ 357b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 358b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* first 8 bits indicate values in optional slots */ 359b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum { 360b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_LOWER, 361b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_FOLD, 362b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_UPPER, 363b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_TITLE, 364b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_4, /* reserved */ 365b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_5, /* reserved */ 366b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_CLOSURE, 367b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_FULL_MAPPINGS, 368b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_ALL_SLOTS /* one past the last slot */ 369b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 370b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 371b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* each slot is 2 uint16_t instead of 1 */ 372b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_EXC_DOUBLE_SLOTS 0x100 373b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 37483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius/* reserved: exception bits 11..9 */ 375b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 376b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* UCASE_EXC_DOT_MASK=UCASE_DOT_MASK<<UCASE_EXC_DOT_SHIFT */ 37783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#define UCASE_EXC_DOT_SHIFT 7 378b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 379b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* normally stored in the main word, but pushed out for larger exception indexes */ 380b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_EXC_DOT_MASK 0x3000 381b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum { 382b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_NO_DOT=0, 383b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_SOFT_DOTTED=0x1000, 384b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_ABOVE=0x2000, /* "above" accents with cc=230 */ 385b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_EXC_OTHER_ACCENT=0x3000 /* other character (0<cc!=230) */ 386b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 387b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 388b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* complex/conditional mappings */ 389b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_EXC_CONDITIONAL_SPECIAL 0x4000 390b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_EXC_CONDITIONAL_FOLD 0x8000 391b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 392b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* definitions for lengths word for full case mappings */ 393b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_FULL_LOWER 0xf 394b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_FULL_FOLDING 0xf0 395b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_FULL_UPPER 0xf00 396b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_FULL_TITLE 0xf000 397b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 398b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* maximum lengths */ 399b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_FULL_MAPPINGS_MAX_LENGTH (4*0xf) 400b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define UCASE_CLOSURE_MAX_LENGTH 0xf 401b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 402b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* constants for reverse case folding ("unfold") data */ 403b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum { 404b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_UNFOLD_ROWS, 405b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_UNFOLD_ROW_WIDTH, 406b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCASE_UNFOLD_STRING_WIDTH 407b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 408b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 409b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 410