Path: blob/jdk8u272-b10-aarch32-20201026/jdk/src/share/native/common/unicode/ucasemap.h
48773 views
// © 2016 and later: Unicode, Inc. and others.1// License & terms of use: http://www.unicode.org/copyright.html2/*3*******************************************************************************4*5* Copyright (C) 2005-2012, International Business Machines6* Corporation and others. All Rights Reserved.7*8*******************************************************************************9* file name: ucasemap.h10* encoding: UTF-811* tab size: 8 (not used)12* indentation:413*14* created on: 2005may0615* created by: Markus W. Scherer16*17* Case mapping service object and functions using it.18*/1920#ifndef __UCASEMAP_H__21#define __UCASEMAP_H__2223#include "unicode/utypes.h"24#include "unicode/localpointer.h"25#include "unicode/stringoptions.h"26#include "unicode/ustring.h"2728/**29* \file30* \brief C API: Unicode case mapping functions using a UCaseMap service object.31*32* The service object takes care of memory allocations, data loading, and setup33* for the attributes, as usual.34*35* Currently, the functionality provided here does not overlap with uchar.h36* and ustring.h, except for ucasemap_toTitle().37*38* ucasemap_utf8XYZ() functions operate directly on UTF-8 strings.39*/4041/**42* UCaseMap is an opaque service object for newer ICU case mapping functions.43* Older functions did not use a service object.44* @stable ICU 3.445*/46struct UCaseMap;47typedef struct UCaseMap UCaseMap; /**< C typedef for struct UCaseMap. @stable ICU 3.4 */4849/**50* Open a UCaseMap service object for a locale and a set of options.51* The locale ID and options are preprocessed so that functions using the52* service object need not process them in each call.53*54* @param locale ICU locale ID, used for language-dependent55* upper-/lower-/title-casing according to the Unicode standard.56* Usual semantics: ""=root, NULL=default locale, etc.57* @param options Options bit set, used for case folding and string comparisons.58* Same flags as for u_foldCase(), u_strFoldCase(),59* u_strCaseCompare(), etc.60* Use 0 or U_FOLD_CASE_DEFAULT for default behavior.61* @param pErrorCode Must be a valid pointer to an error code value,62* which must not indicate a failure before the function call.63* @return Pointer to a UCaseMap service object, if successful.64*65* @see U_FOLD_CASE_DEFAULT66* @see U_FOLD_CASE_EXCLUDE_SPECIAL_I67* @see U_TITLECASE_NO_LOWERCASE68* @see U_TITLECASE_NO_BREAK_ADJUSTMENT69* @stable ICU 3.470*/71U_STABLE UCaseMap * U_EXPORT272ucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode);7374/**75* Close a UCaseMap service object.76* @param csm Object to be closed.77* @stable ICU 3.478*/79U_STABLE void U_EXPORT280ucasemap_close(UCaseMap *csm);8182#if U_SHOW_CPLUSPLUS_API8384U_NAMESPACE_BEGIN8586/**87* \class LocalUCaseMapPointer88* "Smart pointer" class, closes a UCaseMap via ucasemap_close().89* For most methods see the LocalPointerBase base class.90*91* @see LocalPointerBase92* @see LocalPointer93* @stable ICU 4.494*/95U_DEFINE_LOCAL_OPEN_POINTER(LocalUCaseMapPointer, UCaseMap, ucasemap_close);9697U_NAMESPACE_END9899#endif100101/**102* Get the locale ID that is used for language-dependent case mappings.103* @param csm UCaseMap service object.104* @return locale ID105* @stable ICU 3.4106*/107U_STABLE const char * U_EXPORT2108ucasemap_getLocale(const UCaseMap *csm);109110/**111* Get the options bit set that is used for case folding and string comparisons.112* @param csm UCaseMap service object.113* @return options bit set114* @stable ICU 3.4115*/116U_STABLE uint32_t U_EXPORT2117ucasemap_getOptions(const UCaseMap *csm);118119/**120* Set the locale ID that is used for language-dependent case mappings.121*122* @param csm UCaseMap service object.123* @param locale Locale ID, see ucasemap_open().124* @param pErrorCode Must be a valid pointer to an error code value,125* which must not indicate a failure before the function call.126*127* @see ucasemap_open128* @stable ICU 3.4129*/130U_STABLE void U_EXPORT2131ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode);132133/**134* Set the options bit set that is used for case folding and string comparisons.135*136* @param csm UCaseMap service object.137* @param options Options bit set, see ucasemap_open().138* @param pErrorCode Must be a valid pointer to an error code value,139* which must not indicate a failure before the function call.140*141* @see ucasemap_open142* @stable ICU 3.4143*/144U_STABLE void U_EXPORT2145ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode);146147#if !UCONFIG_NO_BREAK_ITERATION148149/**150* Get the break iterator that is used for titlecasing.151* Do not modify the returned break iterator.152* @param csm UCaseMap service object.153* @return titlecasing break iterator154* @stable ICU 3.8155*/156U_STABLE const UBreakIterator * U_EXPORT2157ucasemap_getBreakIterator(const UCaseMap *csm);158159/**160* Set the break iterator that is used for titlecasing.161* The UCaseMap service object releases a previously set break iterator162* and "adopts" this new one, taking ownership of it.163* It will be released in a subsequent call to ucasemap_setBreakIterator()164* or ucasemap_close().165*166* Break iterator operations are not thread-safe. Therefore, titlecasing167* functions use non-const UCaseMap objects. It is not possible to titlecase168* strings concurrently using the same UCaseMap.169*170* @param csm UCaseMap service object.171* @param iterToAdopt Break iterator to be adopted for titlecasing.172* @param pErrorCode Must be a valid pointer to an error code value,173* which must not indicate a failure before the function call.174*175* @see ucasemap_toTitle176* @see ucasemap_utf8ToTitle177* @stable ICU 3.8178*/179U_STABLE void U_EXPORT2180ucasemap_setBreakIterator(UCaseMap *csm, UBreakIterator *iterToAdopt, UErrorCode *pErrorCode);181182/**183* Titlecase a UTF-16 string. This function is almost a duplicate of u_strToTitle(),184* except that it takes ucasemap_setOptions() into account and has performance185* advantages from being able to use a UCaseMap object for multiple case mapping186* operations, saving setup time.187*188* Casing is locale-dependent and context-sensitive.189* Titlecasing uses a break iterator to find the first characters of words190* that are to be titlecased. It titlecases those characters and lowercases191* all others. (This can be modified with ucasemap_setOptions().)192*193* Note: This function takes a non-const UCaseMap pointer because it will194* open a default break iterator if no break iterator was set yet,195* and effectively call ucasemap_setBreakIterator();196* also because the break iterator is stateful and will be modified during197* the iteration.198*199* The titlecase break iterator can be provided to customize for arbitrary200* styles, using rules and dictionaries beyond the standard iterators.201* The standard titlecase iterator for the root locale implements the202* algorithm of Unicode TR 21.203*204* This function uses only the setText(), first() and next() methods of the205* provided break iterator.206*207* The result may be longer or shorter than the original.208* The source string and the destination buffer must not overlap.209*210* @param csm UCaseMap service object. This pointer is non-const!211* See the note above for details.212* @param dest A buffer for the result string. The result will be NUL-terminated if213* the buffer is large enough.214* The contents is undefined in case of failure.215* @param destCapacity The size of the buffer (number of UChars). If it is 0, then216* dest may be NULL and the function will only return the length of the result217* without writing any of the result string.218* @param src The original string.219* @param srcLength The length of the original string. If -1, then src must be NUL-terminated.220* @param pErrorCode Must be a valid pointer to an error code value,221* which must not indicate a failure before the function call.222* @return The length of the result string, if successful - or in case of a buffer overflow,223* in which case it will be greater than destCapacity.224*225* @see u_strToTitle226* @stable ICU 3.8227*/228U_STABLE int32_t U_EXPORT2229ucasemap_toTitle(UCaseMap *csm,230UChar *dest, int32_t destCapacity,231const UChar *src, int32_t srcLength,232UErrorCode *pErrorCode);233234#endif // UCONFIG_NO_BREAK_ITERATION235236/**237* Lowercase the characters in a UTF-8 string.238* Casing is locale-dependent and context-sensitive.239* The result may be longer or shorter than the original.240* The source string and the destination buffer must not overlap.241*242* @param csm UCaseMap service object.243* @param dest A buffer for the result string. The result will be NUL-terminated if244* the buffer is large enough.245* The contents is undefined in case of failure.246* @param destCapacity The size of the buffer (number of bytes). If it is 0, then247* dest may be NULL and the function will only return the length of the result248* without writing any of the result string.249* @param src The original string.250* @param srcLength The length of the original string. If -1, then src must be NUL-terminated.251* @param pErrorCode Must be a valid pointer to an error code value,252* which must not indicate a failure before the function call.253* @return The length of the result string, if successful - or in case of a buffer overflow,254* in which case it will be greater than destCapacity.255*256* @see u_strToLower257* @stable ICU 3.4258*/259U_STABLE int32_t U_EXPORT2260ucasemap_utf8ToLower(const UCaseMap *csm,261char *dest, int32_t destCapacity,262const char *src, int32_t srcLength,263UErrorCode *pErrorCode);264265/**266* Uppercase the characters in a UTF-8 string.267* Casing is locale-dependent and context-sensitive.268* The result may be longer or shorter than the original.269* The source string and the destination buffer must not overlap.270*271* @param csm UCaseMap service object.272* @param dest A buffer for the result string. The result will be NUL-terminated if273* the buffer is large enough.274* The contents is undefined in case of failure.275* @param destCapacity The size of the buffer (number of bytes). If it is 0, then276* dest may be NULL and the function will only return the length of the result277* without writing any of the result string.278* @param src The original string.279* @param srcLength The length of the original string. If -1, then src must be NUL-terminated.280* @param pErrorCode Must be a valid pointer to an error code value,281* which must not indicate a failure before the function call.282* @return The length of the result string, if successful - or in case of a buffer overflow,283* in which case it will be greater than destCapacity.284*285* @see u_strToUpper286* @stable ICU 3.4287*/288U_STABLE int32_t U_EXPORT2289ucasemap_utf8ToUpper(const UCaseMap *csm,290char *dest, int32_t destCapacity,291const char *src, int32_t srcLength,292UErrorCode *pErrorCode);293294#if !UCONFIG_NO_BREAK_ITERATION295296/**297* Titlecase a UTF-8 string.298* Casing is locale-dependent and context-sensitive.299* Titlecasing uses a break iterator to find the first characters of words300* that are to be titlecased. It titlecases those characters and lowercases301* all others. (This can be modified with ucasemap_setOptions().)302*303* Note: This function takes a non-const UCaseMap pointer because it will304* open a default break iterator if no break iterator was set yet,305* and effectively call ucasemap_setBreakIterator();306* also because the break iterator is stateful and will be modified during307* the iteration.308*309* The titlecase break iterator can be provided to customize for arbitrary310* styles, using rules and dictionaries beyond the standard iterators.311* The standard titlecase iterator for the root locale implements the312* algorithm of Unicode TR 21.313*314* This function uses only the setUText(), first(), next() and close() methods of the315* provided break iterator.316*317* The result may be longer or shorter than the original.318* The source string and the destination buffer must not overlap.319*320* @param csm UCaseMap service object. This pointer is non-const!321* See the note above for details.322* @param dest A buffer for the result string. The result will be NUL-terminated if323* the buffer is large enough.324* The contents is undefined in case of failure.325* @param destCapacity The size of the buffer (number of bytes). If it is 0, then326* dest may be NULL and the function will only return the length of the result327* without writing any of the result string.328* @param src The original string.329* @param srcLength The length of the original string. If -1, then src must be NUL-terminated.330* @param pErrorCode Must be a valid pointer to an error code value,331* which must not indicate a failure before the function call.332* @return The length of the result string, if successful - or in case of a buffer overflow,333* in which case it will be greater than destCapacity.334*335* @see u_strToTitle336* @see U_TITLECASE_NO_LOWERCASE337* @see U_TITLECASE_NO_BREAK_ADJUSTMENT338* @stable ICU 3.8339*/340U_STABLE int32_t U_EXPORT2341ucasemap_utf8ToTitle(UCaseMap *csm,342char *dest, int32_t destCapacity,343const char *src, int32_t srcLength,344UErrorCode *pErrorCode);345346#endif347348/**349* Case-folds the characters in a UTF-8 string.350*351* Case-folding is locale-independent and not context-sensitive,352* but there is an option for whether to include or exclude mappings for dotted I353* and dotless i that are marked with 'T' in CaseFolding.txt.354*355* The result may be longer or shorter than the original.356* The source string and the destination buffer must not overlap.357*358* @param csm UCaseMap service object.359* @param dest A buffer for the result string. The result will be NUL-terminated if360* the buffer is large enough.361* The contents is undefined in case of failure.362* @param destCapacity The size of the buffer (number of bytes). If it is 0, then363* dest may be NULL and the function will only return the length of the result364* without writing any of the result string.365* @param src The original string.366* @param srcLength The length of the original string. If -1, then src must be NUL-terminated.367* @param pErrorCode Must be a valid pointer to an error code value,368* which must not indicate a failure before the function call.369* @return The length of the result string, if successful - or in case of a buffer overflow,370* in which case it will be greater than destCapacity.371*372* @see u_strFoldCase373* @see ucasemap_setOptions374* @see U_FOLD_CASE_DEFAULT375* @see U_FOLD_CASE_EXCLUDE_SPECIAL_I376* @stable ICU 3.8377*/378U_STABLE int32_t U_EXPORT2379ucasemap_utf8FoldCase(const UCaseMap *csm,380char *dest, int32_t destCapacity,381const char *src, int32_t srcLength,382UErrorCode *pErrorCode);383384#endif385386387