1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/ucasemap.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,180 @@
1.4 +/*
1.5 +*******************************************************************************
1.6 +*
1.7 +* Copyright (C) 2005, International Business Machines
1.8 +* Corporation and others. All Rights Reserved.
1.9 +*
1.10 +*******************************************************************************
1.11 +* file name: ucasemap.h
1.12 +* encoding: US-ASCII
1.13 +* tab size: 8 (not used)
1.14 +* indentation:4
1.15 +*
1.16 +* created on: 2005may06
1.17 +* created by: Markus W. Scherer
1.18 +*
1.19 +* Case mapping service object and functions using it.
1.20 +*/
1.21 +
1.22 +#ifndef __UCASEMAP_H__
1.23 +#define __UCASEMAP_H__
1.24 +
1.25 +#include "unicode/utypes.h"
1.26 +#include "unicode/ustring.h"
1.27 +
1.28 +/**
1.29 + * \file
1.30 + * \brief C API: Unicode case mapping functions using a UCaseMap service object.
1.31 + *
1.32 + * The service object takes care of memory allocations, data loading, and setup
1.33 + * for the attributes, as usual.
1.34 + *
1.35 + * Currently, the functionality provided here does not overlap with uchar.h
1.36 + * and ustring.h.
1.37 + *
1.38 + * ucasemap_utf8ToLower() and ucasemap_utf8ToUpper() operate directly on
1.39 + * UTF-8 strings.
1.40 + */
1.41 +
1.42 +/**
1.43 + * UCaseMap is an opaque service object for newer ICU case mapping functions.
1.44 + * Older functions did not use a service object.
1.45 + * @draft ICU 3.4
1.46 + */
1.47 +struct UCaseMap;
1.48 +typedef struct UCaseMap UCaseMap; /**< C typedef for struct UCaseMap. @draft ICU 3.4 */
1.49 +
1.50 +/**
1.51 + * Open a UCaseMap service object for a locale and a set of options.
1.52 + * The locale ID and options are preprocessed so that functions using the
1.53 + * service object need not process them in each call.
1.54 + *
1.55 + * @param locale ICU locale ID, used for language-dependent
1.56 + * upper-/lower-/title-casing according to the Unicode standard.
1.57 + * Usual semantics: ""=root, NULL=default locale, etc.
1.58 + * @param options Options bit set, used for case folding and string comparisons.
1.59 + * Same flags as for u_foldCase(), u_strFoldCase(),
1.60 + * u_strCaseCompare(), etc.
1.61 + * Use 0 or U_FOLD_CASE_DEFAULT for default behavior.
1.62 + * @param pErrorCode Must be a valid pointer to an error code value,
1.63 + * which must not indicate a failure before the function call.
1.64 + * @return Pointer to a UCaseMap service object, if successful.
1.65 + *
1.66 + * @draft ICU 3.4
1.67 + */
1.68 +U_DRAFT UCaseMap * U_EXPORT2
1.69 +ucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode);
1.70 +
1.71 +/**
1.72 + * Close a UCaseMap service object.
1.73 + * @param csm Object to be closed.
1.74 + * @draft ICU 3.4
1.75 + */
1.76 +U_DRAFT void U_EXPORT2
1.77 +ucasemap_close(UCaseMap *csm);
1.78 +
1.79 +/**
1.80 + * Get the locale ID that is used for language-dependent case mappings.
1.81 + * @param csm UCaseMap service object.
1.82 + * @return locale ID
1.83 + * @draft ICU 3.4
1.84 + */
1.85 +U_DRAFT const char * U_EXPORT2
1.86 +ucasemap_getLocale(const UCaseMap *csm);
1.87 +
1.88 +/**
1.89 + * Get the options bit set that is used for case folding and string comparisons.
1.90 + * @param csm UCaseMap service object.
1.91 + * @return options bit set
1.92 + * @draft ICU 3.4
1.93 + */
1.94 +U_DRAFT uint32_t U_EXPORT2
1.95 +ucasemap_getOptions(const UCaseMap *csm);
1.96 +
1.97 +/**
1.98 + * Set the locale ID that is used for language-dependent case mappings.
1.99 + *
1.100 + * @param csm UCaseMap service object.
1.101 + * @param locale Locale ID, see ucasemap_open().
1.102 + * @param pErrorCode Must be a valid pointer to an error code value,
1.103 + * which must not indicate a failure before the function call.
1.104 + *
1.105 + * @see ucasemap_open
1.106 + * @draft ICU 3.4
1.107 + */
1.108 +U_DRAFT void U_EXPORT2
1.109 +ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode);
1.110 +
1.111 +/**
1.112 + * Set the options bit set that is used for case folding and string comparisons.
1.113 + *
1.114 + * @param csm UCaseMap service object.
1.115 + * @param options Options bit set, see ucasemap_open().
1.116 + * @param pErrorCode Must be a valid pointer to an error code value,
1.117 + * which must not indicate a failure before the function call.
1.118 + *
1.119 + * @see ucasemap_open
1.120 + * @draft ICU 3.4
1.121 + */
1.122 +U_DRAFT void U_EXPORT2
1.123 +ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode);
1.124 +
1.125 +/**
1.126 + * Lowercase the characters in a UTF-8 string.
1.127 + * Casing is locale-dependent and context-sensitive.
1.128 + * The result may be longer or shorter than the original.
1.129 + * The source string and the destination buffer must not overlap.
1.130 + *
1.131 + * @param csm UCaseMap service object.
1.132 + * @param dest A buffer for the result string. The result will be NUL-terminated if
1.133 + * the buffer is large enough.
1.134 + * The contents is undefined in case of failure.
1.135 + * @param destCapacity The size of the buffer (number of bytes). If it is 0, then
1.136 + * dest may be NULL and the function will only return the length of the result
1.137 + * without writing any of the result string.
1.138 + * @param src The original string
1.139 + * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.
1.140 + * @param pErrorCode Must be a valid pointer to an error code value,
1.141 + * which must not indicate a failure before the function call.
1.142 + * @return The length of the result string, if successful - or in case of a buffer overflow,
1.143 + * in which case it will be greater than destCapacity.
1.144 + *
1.145 + * @see u_strToLower
1.146 + * @draft ICU 3.4
1.147 + */
1.148 +U_DRAFT int32_t U_EXPORT2
1.149 +ucasemap_utf8ToLower(const UCaseMap *csm,
1.150 + char *dest, int32_t destCapacity,
1.151 + const char *src, int32_t srcLength,
1.152 + UErrorCode *pErrorCode);
1.153 +
1.154 +/**
1.155 + * Uppercase the characters in a UTF-8 string.
1.156 + * Casing is locale-dependent and context-sensitive.
1.157 + * The result may be longer or shorter than the original.
1.158 + * The source string and the destination buffer must not overlap.
1.159 + *
1.160 + * @param csm UCaseMap service object.
1.161 + * @param dest A buffer for the result string. The result will be NUL-terminated if
1.162 + * the buffer is large enough.
1.163 + * The contents is undefined in case of failure.
1.164 + * @param destCapacity The size of the buffer (number of bytes). If it is 0, then
1.165 + * dest may be NULL and the function will only return the length of the result
1.166 + * without writing any of the result string.
1.167 + * @param src The original string
1.168 + * @param srcLength The length of the original string. If -1, then src must be NUL-terminated.
1.169 + * @param pErrorCode Must be a valid pointer to an error code value,
1.170 + * which must not indicate a failure before the function call.
1.171 + * @return The length of the result string, if successful - or in case of a buffer overflow,
1.172 + * in which case it will be greater than destCapacity.
1.173 + *
1.174 + * @see u_strToUpper
1.175 + * @draft ICU 3.4
1.176 + */
1.177 +U_DRAFT int32_t U_EXPORT2
1.178 +ucasemap_utf8ToUpper(const UCaseMap *csm,
1.179 + char *dest, int32_t destCapacity,
1.180 + const char *src, int32_t srcLength,
1.181 + UErrorCode *pErrorCode);
1.182 +
1.183 +#endif