intl/icu/source/common/unicode/unorm2.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 *
michael@0 4 * Copyright (C) 2009-2013, International Business Machines
michael@0 5 * Corporation and others. All Rights Reserved.
michael@0 6 *
michael@0 7 *******************************************************************************
michael@0 8 * file name: unorm2.h
michael@0 9 * encoding: US-ASCII
michael@0 10 * tab size: 8 (not used)
michael@0 11 * indentation:4
michael@0 12 *
michael@0 13 * created on: 2009dec15
michael@0 14 * created by: Markus W. Scherer
michael@0 15 */
michael@0 16
michael@0 17 #ifndef __UNORM2_H__
michael@0 18 #define __UNORM2_H__
michael@0 19
michael@0 20 /**
michael@0 21 * \file
michael@0 22 * \brief C API: New API for Unicode Normalization.
michael@0 23 *
michael@0 24 * Unicode normalization functionality for standard Unicode normalization or
michael@0 25 * for using custom mapping tables.
michael@0 26 * All instances of UNormalizer2 are unmodifiable/immutable.
michael@0 27 * Instances returned by unorm2_getInstance() are singletons that must not be deleted by the caller.
michael@0 28 * For more details see the Normalizer2 C++ class.
michael@0 29 */
michael@0 30
michael@0 31 #include "unicode/utypes.h"
michael@0 32 #include "unicode/localpointer.h"
michael@0 33 #include "unicode/uset.h"
michael@0 34
michael@0 35 /**
michael@0 36 * Constants for normalization modes.
michael@0 37 * For details about standard Unicode normalization forms
michael@0 38 * and about the algorithms which are also used with custom mapping tables
michael@0 39 * see http://www.unicode.org/unicode/reports/tr15/
michael@0 40 * @stable ICU 4.4
michael@0 41 */
michael@0 42 typedef enum {
michael@0 43 /**
michael@0 44 * Decomposition followed by composition.
michael@0 45 * Same as standard NFC when using an "nfc" instance.
michael@0 46 * Same as standard NFKC when using an "nfkc" instance.
michael@0 47 * For details about standard Unicode normalization forms
michael@0 48 * see http://www.unicode.org/unicode/reports/tr15/
michael@0 49 * @stable ICU 4.4
michael@0 50 */
michael@0 51 UNORM2_COMPOSE,
michael@0 52 /**
michael@0 53 * Map, and reorder canonically.
michael@0 54 * Same as standard NFD when using an "nfc" instance.
michael@0 55 * Same as standard NFKD when using an "nfkc" instance.
michael@0 56 * For details about standard Unicode normalization forms
michael@0 57 * see http://www.unicode.org/unicode/reports/tr15/
michael@0 58 * @stable ICU 4.4
michael@0 59 */
michael@0 60 UNORM2_DECOMPOSE,
michael@0 61 /**
michael@0 62 * "Fast C or D" form.
michael@0 63 * If a string is in this form, then further decomposition <i>without reordering</i>
michael@0 64 * would yield the same form as DECOMPOSE.
michael@0 65 * Text in "Fast C or D" form can be processed efficiently with data tables
michael@0 66 * that are "canonically closed", that is, that provide equivalent data for
michael@0 67 * equivalent text, without having to be fully normalized.
michael@0 68 * Not a standard Unicode normalization form.
michael@0 69 * Not a unique form: Different FCD strings can be canonically equivalent.
michael@0 70 * For details see http://www.unicode.org/notes/tn5/#FCD
michael@0 71 * @stable ICU 4.4
michael@0 72 */
michael@0 73 UNORM2_FCD,
michael@0 74 /**
michael@0 75 * Compose only contiguously.
michael@0 76 * Also known as "FCC" or "Fast C Contiguous".
michael@0 77 * The result will often but not always be in NFC.
michael@0 78 * The result will conform to FCD which is useful for processing.
michael@0 79 * Not a standard Unicode normalization form.
michael@0 80 * For details see http://www.unicode.org/notes/tn5/#FCC
michael@0 81 * @stable ICU 4.4
michael@0 82 */
michael@0 83 UNORM2_COMPOSE_CONTIGUOUS
michael@0 84 } UNormalization2Mode;
michael@0 85
michael@0 86 /**
michael@0 87 * Result values for normalization quick check functions.
michael@0 88 * For details see http://www.unicode.org/reports/tr15/#Detecting_Normalization_Forms
michael@0 89 * @stable ICU 2.0
michael@0 90 */
michael@0 91 typedef enum UNormalizationCheckResult {
michael@0 92 /**
michael@0 93 * The input string is not in the normalization form.
michael@0 94 * @stable ICU 2.0
michael@0 95 */
michael@0 96 UNORM_NO,
michael@0 97 /**
michael@0 98 * The input string is in the normalization form.
michael@0 99 * @stable ICU 2.0
michael@0 100 */
michael@0 101 UNORM_YES,
michael@0 102 /**
michael@0 103 * The input string may or may not be in the normalization form.
michael@0 104 * This value is only returned for composition forms like NFC and FCC,
michael@0 105 * when a backward-combining character is found for which the surrounding text
michael@0 106 * would have to be analyzed further.
michael@0 107 * @stable ICU 2.0
michael@0 108 */
michael@0 109 UNORM_MAYBE
michael@0 110 } UNormalizationCheckResult;
michael@0 111
michael@0 112 /**
michael@0 113 * Opaque C service object type for the new normalization API.
michael@0 114 * @stable ICU 4.4
michael@0 115 */
michael@0 116 struct UNormalizer2;
michael@0 117 typedef struct UNormalizer2 UNormalizer2; /**< C typedef for struct UNormalizer2. @stable ICU 4.4 */
michael@0 118
michael@0 119 #if !UCONFIG_NO_NORMALIZATION
michael@0 120
michael@0 121 /**
michael@0 122 * Returns a UNormalizer2 instance for Unicode NFC normalization.
michael@0 123 * Same as unorm2_getInstance(NULL, "nfc", UNORM2_COMPOSE, pErrorCode).
michael@0 124 * Returns an unmodifiable singleton instance. Do not delete it.
michael@0 125 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 126 * pass the U_SUCCESS() test, or else the function returns
michael@0 127 * immediately. Check for U_FAILURE() on output or use with
michael@0 128 * function chaining. (See User Guide for details.)
michael@0 129 * @return the requested Normalizer2, if successful
michael@0 130 * @stable ICU 49
michael@0 131 */
michael@0 132 U_STABLE const UNormalizer2 * U_EXPORT2
michael@0 133 unorm2_getNFCInstance(UErrorCode *pErrorCode);
michael@0 134
michael@0 135 /**
michael@0 136 * Returns a UNormalizer2 instance for Unicode NFD normalization.
michael@0 137 * Same as unorm2_getInstance(NULL, "nfc", UNORM2_DECOMPOSE, pErrorCode).
michael@0 138 * Returns an unmodifiable singleton instance. Do not delete it.
michael@0 139 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 140 * pass the U_SUCCESS() test, or else the function returns
michael@0 141 * immediately. Check for U_FAILURE() on output or use with
michael@0 142 * function chaining. (See User Guide for details.)
michael@0 143 * @return the requested Normalizer2, if successful
michael@0 144 * @stable ICU 49
michael@0 145 */
michael@0 146 U_STABLE const UNormalizer2 * U_EXPORT2
michael@0 147 unorm2_getNFDInstance(UErrorCode *pErrorCode);
michael@0 148
michael@0 149 /**
michael@0 150 * Returns a UNormalizer2 instance for Unicode NFKC normalization.
michael@0 151 * Same as unorm2_getInstance(NULL, "nfkc", UNORM2_COMPOSE, pErrorCode).
michael@0 152 * Returns an unmodifiable singleton instance. Do not delete it.
michael@0 153 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 154 * pass the U_SUCCESS() test, or else the function returns
michael@0 155 * immediately. Check for U_FAILURE() on output or use with
michael@0 156 * function chaining. (See User Guide for details.)
michael@0 157 * @return the requested Normalizer2, if successful
michael@0 158 * @stable ICU 49
michael@0 159 */
michael@0 160 U_STABLE const UNormalizer2 * U_EXPORT2
michael@0 161 unorm2_getNFKCInstance(UErrorCode *pErrorCode);
michael@0 162
michael@0 163 /**
michael@0 164 * Returns a UNormalizer2 instance for Unicode NFKD normalization.
michael@0 165 * Same as unorm2_getInstance(NULL, "nfkc", UNORM2_DECOMPOSE, pErrorCode).
michael@0 166 * Returns an unmodifiable singleton instance. Do not delete it.
michael@0 167 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 168 * pass the U_SUCCESS() test, or else the function returns
michael@0 169 * immediately. Check for U_FAILURE() on output or use with
michael@0 170 * function chaining. (See User Guide for details.)
michael@0 171 * @return the requested Normalizer2, if successful
michael@0 172 * @stable ICU 49
michael@0 173 */
michael@0 174 U_STABLE const UNormalizer2 * U_EXPORT2
michael@0 175 unorm2_getNFKDInstance(UErrorCode *pErrorCode);
michael@0 176
michael@0 177 /**
michael@0 178 * Returns a UNormalizer2 instance for Unicode NFKC_Casefold normalization.
michael@0 179 * Same as unorm2_getInstance(NULL, "nfkc_cf", UNORM2_COMPOSE, pErrorCode).
michael@0 180 * Returns an unmodifiable singleton instance. Do not delete it.
michael@0 181 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 182 * pass the U_SUCCESS() test, or else the function returns
michael@0 183 * immediately. Check for U_FAILURE() on output or use with
michael@0 184 * function chaining. (See User Guide for details.)
michael@0 185 * @return the requested Normalizer2, if successful
michael@0 186 * @stable ICU 49
michael@0 187 */
michael@0 188 U_STABLE const UNormalizer2 * U_EXPORT2
michael@0 189 unorm2_getNFKCCasefoldInstance(UErrorCode *pErrorCode);
michael@0 190
michael@0 191 /**
michael@0 192 * Returns a UNormalizer2 instance which uses the specified data file
michael@0 193 * (packageName/name similar to ucnv_openPackage() and ures_open()/ResourceBundle)
michael@0 194 * and which composes or decomposes text according to the specified mode.
michael@0 195 * Returns an unmodifiable singleton instance. Do not delete it.
michael@0 196 *
michael@0 197 * Use packageName=NULL for data files that are part of ICU's own data.
michael@0 198 * Use name="nfc" and UNORM2_COMPOSE/UNORM2_DECOMPOSE for Unicode standard NFC/NFD.
michael@0 199 * Use name="nfkc" and UNORM2_COMPOSE/UNORM2_DECOMPOSE for Unicode standard NFKC/NFKD.
michael@0 200 * Use name="nfkc_cf" and UNORM2_COMPOSE for Unicode standard NFKC_CF=NFKC_Casefold.
michael@0 201 *
michael@0 202 * @param packageName NULL for ICU built-in data, otherwise application data package name
michael@0 203 * @param name "nfc" or "nfkc" or "nfkc_cf" or name of custom data file
michael@0 204 * @param mode normalization mode (compose or decompose etc.)
michael@0 205 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 206 * pass the U_SUCCESS() test, or else the function returns
michael@0 207 * immediately. Check for U_FAILURE() on output or use with
michael@0 208 * function chaining. (See User Guide for details.)
michael@0 209 * @return the requested UNormalizer2, if successful
michael@0 210 * @stable ICU 4.4
michael@0 211 */
michael@0 212 U_STABLE const UNormalizer2 * U_EXPORT2
michael@0 213 unorm2_getInstance(const char *packageName,
michael@0 214 const char *name,
michael@0 215 UNormalization2Mode mode,
michael@0 216 UErrorCode *pErrorCode);
michael@0 217
michael@0 218 /**
michael@0 219 * Constructs a filtered normalizer wrapping any UNormalizer2 instance
michael@0 220 * and a filter set.
michael@0 221 * Both are aliased and must not be modified or deleted while this object
michael@0 222 * is used.
michael@0 223 * The filter set should be frozen; otherwise the performance will suffer greatly.
michael@0 224 * @param norm2 wrapped UNormalizer2 instance
michael@0 225 * @param filterSet USet which determines the characters to be normalized
michael@0 226 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 227 * pass the U_SUCCESS() test, or else the function returns
michael@0 228 * immediately. Check for U_FAILURE() on output or use with
michael@0 229 * function chaining. (See User Guide for details.)
michael@0 230 * @return the requested UNormalizer2, if successful
michael@0 231 * @stable ICU 4.4
michael@0 232 */
michael@0 233 U_STABLE UNormalizer2 * U_EXPORT2
michael@0 234 unorm2_openFiltered(const UNormalizer2 *norm2, const USet *filterSet, UErrorCode *pErrorCode);
michael@0 235
michael@0 236 /**
michael@0 237 * Closes a UNormalizer2 instance from unorm2_openFiltered().
michael@0 238 * Do not close instances from unorm2_getInstance()!
michael@0 239 * @param norm2 UNormalizer2 instance to be closed
michael@0 240 * @stable ICU 4.4
michael@0 241 */
michael@0 242 U_STABLE void U_EXPORT2
michael@0 243 unorm2_close(UNormalizer2 *norm2);
michael@0 244
michael@0 245 #if U_SHOW_CPLUSPLUS_API
michael@0 246
michael@0 247 U_NAMESPACE_BEGIN
michael@0 248
michael@0 249 /**
michael@0 250 * \class LocalUNormalizer2Pointer
michael@0 251 * "Smart pointer" class, closes a UNormalizer2 via unorm2_close().
michael@0 252 * For most methods see the LocalPointerBase base class.
michael@0 253 *
michael@0 254 * @see LocalPointerBase
michael@0 255 * @see LocalPointer
michael@0 256 * @stable ICU 4.4
michael@0 257 */
michael@0 258 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNormalizer2Pointer, UNormalizer2, unorm2_close);
michael@0 259
michael@0 260 U_NAMESPACE_END
michael@0 261
michael@0 262 #endif
michael@0 263
michael@0 264 /**
michael@0 265 * Writes the normalized form of the source string to the destination string
michael@0 266 * (replacing its contents) and returns the length of the destination string.
michael@0 267 * The source and destination strings must be different buffers.
michael@0 268 * @param norm2 UNormalizer2 instance
michael@0 269 * @param src source string
michael@0 270 * @param length length of the source string, or -1 if NUL-terminated
michael@0 271 * @param dest destination string; its contents is replaced with normalized src
michael@0 272 * @param capacity number of UChars that can be written to dest
michael@0 273 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 274 * pass the U_SUCCESS() test, or else the function returns
michael@0 275 * immediately. Check for U_FAILURE() on output or use with
michael@0 276 * function chaining. (See User Guide for details.)
michael@0 277 * @return dest
michael@0 278 * @stable ICU 4.4
michael@0 279 */
michael@0 280 U_STABLE int32_t U_EXPORT2
michael@0 281 unorm2_normalize(const UNormalizer2 *norm2,
michael@0 282 const UChar *src, int32_t length,
michael@0 283 UChar *dest, int32_t capacity,
michael@0 284 UErrorCode *pErrorCode);
michael@0 285 /**
michael@0 286 * Appends the normalized form of the second string to the first string
michael@0 287 * (merging them at the boundary) and returns the length of the first string.
michael@0 288 * The result is normalized if the first string was normalized.
michael@0 289 * The first and second strings must be different buffers.
michael@0 290 * @param norm2 UNormalizer2 instance
michael@0 291 * @param first string, should be normalized
michael@0 292 * @param firstLength length of the first string, or -1 if NUL-terminated
michael@0 293 * @param firstCapacity number of UChars that can be written to first
michael@0 294 * @param second string, will be normalized
michael@0 295 * @param secondLength length of the source string, or -1 if NUL-terminated
michael@0 296 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 297 * pass the U_SUCCESS() test, or else the function returns
michael@0 298 * immediately. Check for U_FAILURE() on output or use with
michael@0 299 * function chaining. (See User Guide for details.)
michael@0 300 * @return first
michael@0 301 * @stable ICU 4.4
michael@0 302 */
michael@0 303 U_STABLE int32_t U_EXPORT2
michael@0 304 unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,
michael@0 305 UChar *first, int32_t firstLength, int32_t firstCapacity,
michael@0 306 const UChar *second, int32_t secondLength,
michael@0 307 UErrorCode *pErrorCode);
michael@0 308 /**
michael@0 309 * Appends the second string to the first string
michael@0 310 * (merging them at the boundary) and returns the length of the first string.
michael@0 311 * The result is normalized if both the strings were normalized.
michael@0 312 * The first and second strings must be different buffers.
michael@0 313 * @param norm2 UNormalizer2 instance
michael@0 314 * @param first string, should be normalized
michael@0 315 * @param firstLength length of the first string, or -1 if NUL-terminated
michael@0 316 * @param firstCapacity number of UChars that can be written to first
michael@0 317 * @param second string, should be normalized
michael@0 318 * @param secondLength length of the source string, or -1 if NUL-terminated
michael@0 319 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 320 * pass the U_SUCCESS() test, or else the function returns
michael@0 321 * immediately. Check for U_FAILURE() on output or use with
michael@0 322 * function chaining. (See User Guide for details.)
michael@0 323 * @return first
michael@0 324 * @stable ICU 4.4
michael@0 325 */
michael@0 326 U_STABLE int32_t U_EXPORT2
michael@0 327 unorm2_append(const UNormalizer2 *norm2,
michael@0 328 UChar *first, int32_t firstLength, int32_t firstCapacity,
michael@0 329 const UChar *second, int32_t secondLength,
michael@0 330 UErrorCode *pErrorCode);
michael@0 331
michael@0 332 /**
michael@0 333 * Gets the decomposition mapping of c.
michael@0 334 * Roughly equivalent to normalizing the String form of c
michael@0 335 * on a UNORM2_DECOMPOSE UNormalizer2 instance, but much faster, and except that this function
michael@0 336 * returns a negative value and does not write a string
michael@0 337 * if c does not have a decomposition mapping in this instance's data.
michael@0 338 * This function is independent of the mode of the UNormalizer2.
michael@0 339 * @param norm2 UNormalizer2 instance
michael@0 340 * @param c code point
michael@0 341 * @param decomposition String buffer which will be set to c's
michael@0 342 * decomposition mapping, if there is one.
michael@0 343 * @param capacity number of UChars that can be written to decomposition
michael@0 344 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 345 * pass the U_SUCCESS() test, or else the function returns
michael@0 346 * immediately. Check for U_FAILURE() on output or use with
michael@0 347 * function chaining. (See User Guide for details.)
michael@0 348 * @return the non-negative length of c's decomposition, if there is one; otherwise a negative value
michael@0 349 * @stable ICU 4.6
michael@0 350 */
michael@0 351 U_STABLE int32_t U_EXPORT2
michael@0 352 unorm2_getDecomposition(const UNormalizer2 *norm2,
michael@0 353 UChar32 c, UChar *decomposition, int32_t capacity,
michael@0 354 UErrorCode *pErrorCode);
michael@0 355
michael@0 356 /**
michael@0 357 * Gets the raw decomposition mapping of c.
michael@0 358 *
michael@0 359 * This is similar to the unorm2_getDecomposition() function but returns the
michael@0 360 * raw decomposition mapping as specified in UnicodeData.txt or
michael@0 361 * (for custom data) in the mapping files processed by the gennorm2 tool.
michael@0 362 * By contrast, unorm2_getDecomposition() returns the processed,
michael@0 363 * recursively-decomposed version of this mapping.
michael@0 364 *
michael@0 365 * When used on a standard NFKC Normalizer2 instance,
michael@0 366 * unorm2_getRawDecomposition() returns the Unicode Decomposition_Mapping (dm) property.
michael@0 367 *
michael@0 368 * When used on a standard NFC Normalizer2 instance,
michael@0 369 * it returns the Decomposition_Mapping only if the Decomposition_Type (dt) is Canonical (Can);
michael@0 370 * in this case, the result contains either one or two code points (=1..4 UChars).
michael@0 371 *
michael@0 372 * This function is independent of the mode of the UNormalizer2.
michael@0 373 * @param norm2 UNormalizer2 instance
michael@0 374 * @param c code point
michael@0 375 * @param decomposition String buffer which will be set to c's
michael@0 376 * raw decomposition mapping, if there is one.
michael@0 377 * @param capacity number of UChars that can be written to decomposition
michael@0 378 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 379 * pass the U_SUCCESS() test, or else the function returns
michael@0 380 * immediately. Check for U_FAILURE() on output or use with
michael@0 381 * function chaining. (See User Guide for details.)
michael@0 382 * @return the non-negative length of c's raw decomposition, if there is one; otherwise a negative value
michael@0 383 * @stable ICU 49
michael@0 384 */
michael@0 385 U_STABLE int32_t U_EXPORT2
michael@0 386 unorm2_getRawDecomposition(const UNormalizer2 *norm2,
michael@0 387 UChar32 c, UChar *decomposition, int32_t capacity,
michael@0 388 UErrorCode *pErrorCode);
michael@0 389
michael@0 390 /**
michael@0 391 * Performs pairwise composition of a & b and returns the composite if there is one.
michael@0 392 *
michael@0 393 * Returns a composite code point c only if c has a two-way mapping to a+b.
michael@0 394 * In standard Unicode normalization, this means that
michael@0 395 * c has a canonical decomposition to a+b
michael@0 396 * and c does not have the Full_Composition_Exclusion property.
michael@0 397 *
michael@0 398 * This function is independent of the mode of the UNormalizer2.
michael@0 399 * @param norm2 UNormalizer2 instance
michael@0 400 * @param a A (normalization starter) code point.
michael@0 401 * @param b Another code point.
michael@0 402 * @return The non-negative composite code point if there is one; otherwise a negative value.
michael@0 403 * @stable ICU 49
michael@0 404 */
michael@0 405 U_STABLE UChar32 U_EXPORT2
michael@0 406 unorm2_composePair(const UNormalizer2 *norm2, UChar32 a, UChar32 b);
michael@0 407
michael@0 408 /**
michael@0 409 * Gets the combining class of c.
michael@0 410 * The default implementation returns 0
michael@0 411 * but all standard implementations return the Unicode Canonical_Combining_Class value.
michael@0 412 * @param norm2 UNormalizer2 instance
michael@0 413 * @param c code point
michael@0 414 * @return c's combining class
michael@0 415 * @stable ICU 49
michael@0 416 */
michael@0 417 U_STABLE uint8_t U_EXPORT2
michael@0 418 unorm2_getCombiningClass(const UNormalizer2 *norm2, UChar32 c);
michael@0 419
michael@0 420 /**
michael@0 421 * Tests if the string is normalized.
michael@0 422 * Internally, in cases where the quickCheck() method would return "maybe"
michael@0 423 * (which is only possible for the two COMPOSE modes) this method
michael@0 424 * resolves to "yes" or "no" to provide a definitive result,
michael@0 425 * at the cost of doing more work in those cases.
michael@0 426 * @param norm2 UNormalizer2 instance
michael@0 427 * @param s input string
michael@0 428 * @param length length of the string, or -1 if NUL-terminated
michael@0 429 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 430 * pass the U_SUCCESS() test, or else the function returns
michael@0 431 * immediately. Check for U_FAILURE() on output or use with
michael@0 432 * function chaining. (See User Guide for details.)
michael@0 433 * @return TRUE if s is normalized
michael@0 434 * @stable ICU 4.4
michael@0 435 */
michael@0 436 U_STABLE UBool U_EXPORT2
michael@0 437 unorm2_isNormalized(const UNormalizer2 *norm2,
michael@0 438 const UChar *s, int32_t length,
michael@0 439 UErrorCode *pErrorCode);
michael@0 440
michael@0 441 /**
michael@0 442 * Tests if the string is normalized.
michael@0 443 * For the two COMPOSE modes, the result could be "maybe" in cases that
michael@0 444 * would take a little more work to resolve definitively.
michael@0 445 * Use spanQuickCheckYes() and normalizeSecondAndAppend() for a faster
michael@0 446 * combination of quick check + normalization, to avoid
michael@0 447 * re-checking the "yes" prefix.
michael@0 448 * @param norm2 UNormalizer2 instance
michael@0 449 * @param s input string
michael@0 450 * @param length length of the string, or -1 if NUL-terminated
michael@0 451 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 452 * pass the U_SUCCESS() test, or else the function returns
michael@0 453 * immediately. Check for U_FAILURE() on output or use with
michael@0 454 * function chaining. (See User Guide for details.)
michael@0 455 * @return UNormalizationCheckResult
michael@0 456 * @stable ICU 4.4
michael@0 457 */
michael@0 458 U_STABLE UNormalizationCheckResult U_EXPORT2
michael@0 459 unorm2_quickCheck(const UNormalizer2 *norm2,
michael@0 460 const UChar *s, int32_t length,
michael@0 461 UErrorCode *pErrorCode);
michael@0 462
michael@0 463 /**
michael@0 464 * Returns the end of the normalized substring of the input string.
michael@0 465 * In other words, with <code>end=spanQuickCheckYes(s, ec);</code>
michael@0 466 * the substring <code>UnicodeString(s, 0, end)</code>
michael@0 467 * will pass the quick check with a "yes" result.
michael@0 468 *
michael@0 469 * The returned end index is usually one or more characters before the
michael@0 470 * "no" or "maybe" character: The end index is at a normalization boundary.
michael@0 471 * (See the class documentation for more about normalization boundaries.)
michael@0 472 *
michael@0 473 * When the goal is a normalized string and most input strings are expected
michael@0 474 * to be normalized already, then call this method,
michael@0 475 * and if it returns a prefix shorter than the input string,
michael@0 476 * copy that prefix and use normalizeSecondAndAppend() for the remainder.
michael@0 477 * @param norm2 UNormalizer2 instance
michael@0 478 * @param s input string
michael@0 479 * @param length length of the string, or -1 if NUL-terminated
michael@0 480 * @param pErrorCode Standard ICU error code. Its input value must
michael@0 481 * pass the U_SUCCESS() test, or else the function returns
michael@0 482 * immediately. Check for U_FAILURE() on output or use with
michael@0 483 * function chaining. (See User Guide for details.)
michael@0 484 * @return "yes" span end index
michael@0 485 * @stable ICU 4.4
michael@0 486 */
michael@0 487 U_STABLE int32_t U_EXPORT2
michael@0 488 unorm2_spanQuickCheckYes(const UNormalizer2 *norm2,
michael@0 489 const UChar *s, int32_t length,
michael@0 490 UErrorCode *pErrorCode);
michael@0 491
michael@0 492 /**
michael@0 493 * Tests if the character always has a normalization boundary before it,
michael@0 494 * regardless of context.
michael@0 495 * For details see the Normalizer2 base class documentation.
michael@0 496 * @param norm2 UNormalizer2 instance
michael@0 497 * @param c character to test
michael@0 498 * @return TRUE if c has a normalization boundary before it
michael@0 499 * @stable ICU 4.4
michael@0 500 */
michael@0 501 U_STABLE UBool U_EXPORT2
michael@0 502 unorm2_hasBoundaryBefore(const UNormalizer2 *norm2, UChar32 c);
michael@0 503
michael@0 504 /**
michael@0 505 * Tests if the character always has a normalization boundary after it,
michael@0 506 * regardless of context.
michael@0 507 * For details see the Normalizer2 base class documentation.
michael@0 508 * @param norm2 UNormalizer2 instance
michael@0 509 * @param c character to test
michael@0 510 * @return TRUE if c has a normalization boundary after it
michael@0 511 * @stable ICU 4.4
michael@0 512 */
michael@0 513 U_STABLE UBool U_EXPORT2
michael@0 514 unorm2_hasBoundaryAfter(const UNormalizer2 *norm2, UChar32 c);
michael@0 515
michael@0 516 /**
michael@0 517 * Tests if the character is normalization-inert.
michael@0 518 * For details see the Normalizer2 base class documentation.
michael@0 519 * @param norm2 UNormalizer2 instance
michael@0 520 * @param c character to test
michael@0 521 * @return TRUE if c is normalization-inert
michael@0 522 * @stable ICU 4.4
michael@0 523 */
michael@0 524 U_STABLE UBool U_EXPORT2
michael@0 525 unorm2_isInert(const UNormalizer2 *norm2, UChar32 c);
michael@0 526
michael@0 527 #endif /* !UCONFIG_NO_NORMALIZATION */
michael@0 528 #endif /* __UNORM2_H__ */

mercurial