sl@0: /* sl@0: ******************************************************************************* sl@0: * sl@0: * Copyright (C) 2005, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: * sl@0: ******************************************************************************* sl@0: * file name: ucasemap.h sl@0: * encoding: US-ASCII sl@0: * tab size: 8 (not used) sl@0: * indentation:4 sl@0: * sl@0: * created on: 2005may06 sl@0: * created by: Markus W. Scherer sl@0: * sl@0: * Case mapping service object and functions using it. sl@0: */ sl@0: sl@0: #ifndef __UCASEMAP_H__ sl@0: #define __UCASEMAP_H__ sl@0: sl@0: #include "unicode/utypes.h" sl@0: #include "unicode/ustring.h" sl@0: sl@0: /** sl@0: * \file sl@0: * \brief C API: Unicode case mapping functions using a UCaseMap service object. sl@0: * sl@0: * The service object takes care of memory allocations, data loading, and setup sl@0: * for the attributes, as usual. sl@0: * sl@0: * Currently, the functionality provided here does not overlap with uchar.h sl@0: * and ustring.h. sl@0: * sl@0: * ucasemap_utf8ToLower() and ucasemap_utf8ToUpper() operate directly on sl@0: * UTF-8 strings. sl@0: */ sl@0: sl@0: /** sl@0: * UCaseMap is an opaque service object for newer ICU case mapping functions. sl@0: * Older functions did not use a service object. sl@0: * @draft ICU 3.4 sl@0: */ sl@0: struct UCaseMap; sl@0: typedef struct UCaseMap UCaseMap; /**< C typedef for struct UCaseMap. @draft ICU 3.4 */ sl@0: sl@0: /** sl@0: * Open a UCaseMap service object for a locale and a set of options. sl@0: * The locale ID and options are preprocessed so that functions using the sl@0: * service object need not process them in each call. sl@0: * sl@0: * @param locale ICU locale ID, used for language-dependent sl@0: * upper-/lower-/title-casing according to the Unicode standard. sl@0: * Usual semantics: ""=root, NULL=default locale, etc. sl@0: * @param options Options bit set, used for case folding and string comparisons. sl@0: * Same flags as for u_foldCase(), u_strFoldCase(), sl@0: * u_strCaseCompare(), etc. sl@0: * Use 0 or U_FOLD_CASE_DEFAULT for default behavior. sl@0: * @param pErrorCode Must be a valid pointer to an error code value, sl@0: * which must not indicate a failure before the function call. sl@0: * @return Pointer to a UCaseMap service object, if successful. sl@0: * sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT UCaseMap * U_EXPORT2 sl@0: ucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Close a UCaseMap service object. sl@0: * @param csm Object to be closed. sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: ucasemap_close(UCaseMap *csm); sl@0: sl@0: /** sl@0: * Get the locale ID that is used for language-dependent case mappings. sl@0: * @param csm UCaseMap service object. sl@0: * @return locale ID sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT const char * U_EXPORT2 sl@0: ucasemap_getLocale(const UCaseMap *csm); sl@0: sl@0: /** sl@0: * Get the options bit set that is used for case folding and string comparisons. sl@0: * @param csm UCaseMap service object. sl@0: * @return options bit set sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT uint32_t U_EXPORT2 sl@0: ucasemap_getOptions(const UCaseMap *csm); sl@0: sl@0: /** sl@0: * Set the locale ID that is used for language-dependent case mappings. sl@0: * sl@0: * @param csm UCaseMap service object. sl@0: * @param locale Locale ID, see ucasemap_open(). sl@0: * @param pErrorCode Must be a valid pointer to an error code value, sl@0: * which must not indicate a failure before the function call. sl@0: * sl@0: * @see ucasemap_open sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Set the options bit set that is used for case folding and string comparisons. sl@0: * sl@0: * @param csm UCaseMap service object. sl@0: * @param options Options bit set, see ucasemap_open(). sl@0: * @param pErrorCode Must be a valid pointer to an error code value, sl@0: * which must not indicate a failure before the function call. sl@0: * sl@0: * @see ucasemap_open sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT void U_EXPORT2 sl@0: ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Lowercase the characters in a UTF-8 string. sl@0: * Casing is locale-dependent and context-sensitive. sl@0: * The result may be longer or shorter than the original. sl@0: * The source string and the destination buffer must not overlap. sl@0: * sl@0: * @param csm UCaseMap service object. sl@0: * @param dest A buffer for the result string. The result will be NUL-terminated if sl@0: * the buffer is large enough. sl@0: * The contents is undefined in case of failure. sl@0: * @param destCapacity The size of the buffer (number of bytes). If it is 0, then sl@0: * dest may be NULL and the function will only return the length of the result sl@0: * without writing any of the result string. sl@0: * @param src The original string sl@0: * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. sl@0: * @param pErrorCode Must be a valid pointer to an error code value, sl@0: * which must not indicate a failure before the function call. sl@0: * @return The length of the result string, if successful - or in case of a buffer overflow, sl@0: * in which case it will be greater than destCapacity. sl@0: * sl@0: * @see u_strToLower sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT int32_t U_EXPORT2 sl@0: ucasemap_utf8ToLower(const UCaseMap *csm, sl@0: char *dest, int32_t destCapacity, sl@0: const char *src, int32_t srcLength, sl@0: UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Uppercase the characters in a UTF-8 string. sl@0: * Casing is locale-dependent and context-sensitive. sl@0: * The result may be longer or shorter than the original. sl@0: * The source string and the destination buffer must not overlap. sl@0: * sl@0: * @param csm UCaseMap service object. sl@0: * @param dest A buffer for the result string. The result will be NUL-terminated if sl@0: * the buffer is large enough. sl@0: * The contents is undefined in case of failure. sl@0: * @param destCapacity The size of the buffer (number of bytes). If it is 0, then sl@0: * dest may be NULL and the function will only return the length of the result sl@0: * without writing any of the result string. sl@0: * @param src The original string sl@0: * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. sl@0: * @param pErrorCode Must be a valid pointer to an error code value, sl@0: * which must not indicate a failure before the function call. sl@0: * @return The length of the result string, if successful - or in case of a buffer overflow, sl@0: * in which case it will be greater than destCapacity. sl@0: * sl@0: * @see u_strToUpper sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT int32_t U_EXPORT2 sl@0: ucasemap_utf8ToUpper(const UCaseMap *csm, sl@0: char *dest, int32_t destCapacity, sl@0: const char *src, int32_t srcLength, sl@0: UErrorCode *pErrorCode); sl@0: sl@0: #endif