Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/unicode/unorm2.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // © 2016 and later: Unicode, Inc. and others.
0002 // License & terms of use: http://www.unicode.org/copyright.html
0003 /*
0004 *******************************************************************************
0005 *
0006 *   Copyright (C) 2009-2015, International Business Machines
0007 *   Corporation and others.  All Rights Reserved.
0008 *
0009 *******************************************************************************
0010 *   file name:  unorm2.h
0011 *   encoding:   UTF-8
0012 *   tab size:   8 (not used)
0013 *   indentation:4
0014 *
0015 *   created on: 2009dec15
0016 *   created by: Markus W. Scherer
0017 */
0018 
0019 #ifndef __UNORM2_H__
0020 #define __UNORM2_H__
0021 
0022 /**
0023  * \file
0024  * \brief C API: New API for Unicode Normalization.
0025  *
0026  * Unicode normalization functionality for standard Unicode normalization or
0027  * for using custom mapping tables.
0028  * All instances of UNormalizer2 are unmodifiable/immutable.
0029  * Instances returned by unorm2_getInstance() are singletons that must not be deleted by the caller.
0030  * For more details see the Normalizer2 C++ class.
0031  */
0032 
0033 #include "unicode/utypes.h"
0034 #include "unicode/stringoptions.h"
0035 #include "unicode/uset.h"
0036 
0037 #if U_SHOW_CPLUSPLUS_API
0038 #include "unicode/localpointer.h"
0039 #endif   // U_SHOW_CPLUSPLUS_API
0040 
0041 /**
0042  * Constants for normalization modes.
0043  * For details about standard Unicode normalization forms
0044  * and about the algorithms which are also used with custom mapping tables
0045  * see http://www.unicode.org/unicode/reports/tr15/
0046  * @stable ICU 4.4
0047  */
0048 typedef enum {
0049     /**
0050      * Decomposition followed by composition.
0051      * Same as standard NFC when using an "nfc" instance.
0052      * Same as standard NFKC when using an "nfkc" instance.
0053      * For details about standard Unicode normalization forms
0054      * see http://www.unicode.org/unicode/reports/tr15/
0055      * @stable ICU 4.4
0056      */
0057     UNORM2_COMPOSE,
0058     /**
0059      * Map, and reorder canonically.
0060      * Same as standard NFD when using an "nfc" instance.
0061      * Same as standard NFKD when using an "nfkc" instance.
0062      * For details about standard Unicode normalization forms
0063      * see http://www.unicode.org/unicode/reports/tr15/
0064      * @stable ICU 4.4
0065      */
0066     UNORM2_DECOMPOSE,
0067     /**
0068      * "Fast C or D" form.
0069      * If a string is in this form, then further decomposition <i>without reordering</i>
0070      * would yield the same form as DECOMPOSE.
0071      * Text in "Fast C or D" form can be processed efficiently with data tables
0072      * that are "canonically closed", that is, that provide equivalent data for
0073      * equivalent text, without having to be fully normalized.
0074      * Not a standard Unicode normalization form.
0075      * Not a unique form: Different FCD strings can be canonically equivalent.
0076      * For details see http://www.unicode.org/notes/tn5/#FCD
0077      * @stable ICU 4.4
0078      */
0079     UNORM2_FCD,
0080     /**
0081      * Compose only contiguously.
0082      * Also known as "FCC" or "Fast C Contiguous".
0083      * The result will often but not always be in NFC.
0084      * The result will conform to FCD which is useful for processing.
0085      * Not a standard Unicode normalization form.
0086      * For details see http://www.unicode.org/notes/tn5/#FCC
0087      * @stable ICU 4.4
0088      */
0089     UNORM2_COMPOSE_CONTIGUOUS
0090 } UNormalization2Mode;
0091 
0092 /**
0093  * Result values for normalization quick check functions.
0094  * For details see http://www.unicode.org/reports/tr15/#Detecting_Normalization_Forms
0095  * @stable ICU 2.0
0096  */
0097 typedef enum UNormalizationCheckResult {
0098   /**
0099    * The input string is not in the normalization form.
0100    * @stable ICU 2.0
0101    */
0102   UNORM_NO,
0103   /**
0104    * The input string is in the normalization form.
0105    * @stable ICU 2.0
0106    */
0107   UNORM_YES,
0108   /**
0109    * The input string may or may not be in the normalization form.
0110    * This value is only returned for composition forms like NFC and FCC,
0111    * when a backward-combining character is found for which the surrounding text
0112    * would have to be analyzed further.
0113    * @stable ICU 2.0
0114    */
0115   UNORM_MAYBE
0116 } UNormalizationCheckResult;
0117 
0118 /**
0119  * Opaque C service object type for the new normalization API.
0120  * @stable ICU 4.4
0121  */
0122 struct UNormalizer2;
0123 typedef struct UNormalizer2 UNormalizer2;  /**< C typedef for struct UNormalizer2. @stable ICU 4.4 */
0124 
0125 #if !UCONFIG_NO_NORMALIZATION
0126 
0127 /**
0128  * Returns a UNormalizer2 instance for Unicode NFC normalization.
0129  * Same as unorm2_getInstance(NULL, "nfc", UNORM2_COMPOSE, pErrorCode).
0130  * Returns an unmodifiable singleton instance. Do not delete it.
0131  * @param pErrorCode Standard ICU error code. Its input value must
0132  *                  pass the U_SUCCESS() test, or else the function returns
0133  *                  immediately. Check for U_FAILURE() on output or use with
0134  *                  function chaining. (See User Guide for details.)
0135  * @return the requested Normalizer2, if successful
0136  * @stable ICU 49
0137  */
0138 U_CAPI const UNormalizer2 * U_EXPORT2
0139 unorm2_getNFCInstance(UErrorCode *pErrorCode);
0140 
0141 /**
0142  * Returns a UNormalizer2 instance for Unicode NFD normalization.
0143  * Same as unorm2_getInstance(NULL, "nfc", UNORM2_DECOMPOSE, pErrorCode).
0144  * Returns an unmodifiable singleton instance. Do not delete it.
0145  * @param pErrorCode Standard ICU error code. Its input value must
0146  *                  pass the U_SUCCESS() test, or else the function returns
0147  *                  immediately. Check for U_FAILURE() on output or use with
0148  *                  function chaining. (See User Guide for details.)
0149  * @return the requested Normalizer2, if successful
0150  * @stable ICU 49
0151  */
0152 U_CAPI const UNormalizer2 * U_EXPORT2
0153 unorm2_getNFDInstance(UErrorCode *pErrorCode);
0154 
0155 /**
0156  * Returns a UNormalizer2 instance for Unicode NFKC normalization.
0157  * Same as unorm2_getInstance(NULL, "nfkc", UNORM2_COMPOSE, pErrorCode).
0158  * Returns an unmodifiable singleton instance. Do not delete it.
0159  * @param pErrorCode Standard ICU error code. Its input value must
0160  *                  pass the U_SUCCESS() test, or else the function returns
0161  *                  immediately. Check for U_FAILURE() on output or use with
0162  *                  function chaining. (See User Guide for details.)
0163  * @return the requested Normalizer2, if successful
0164  * @stable ICU 49
0165  */
0166 U_CAPI const UNormalizer2 * U_EXPORT2
0167 unorm2_getNFKCInstance(UErrorCode *pErrorCode);
0168 
0169 /**
0170  * Returns a UNormalizer2 instance for Unicode NFKD normalization.
0171  * Same as unorm2_getInstance(NULL, "nfkc", UNORM2_DECOMPOSE, pErrorCode).
0172  * Returns an unmodifiable singleton instance. Do not delete it.
0173  * @param pErrorCode Standard ICU error code. Its input value must
0174  *                  pass the U_SUCCESS() test, or else the function returns
0175  *                  immediately. Check for U_FAILURE() on output or use with
0176  *                  function chaining. (See User Guide for details.)
0177  * @return the requested Normalizer2, if successful
0178  * @stable ICU 49
0179  */
0180 U_CAPI const UNormalizer2 * U_EXPORT2
0181 unorm2_getNFKDInstance(UErrorCode *pErrorCode);
0182 
0183 /**
0184  * Returns a UNormalizer2 instance for Unicode toNFKC_Casefold() normalization
0185  * which is equivalent to applying the NFKC_Casefold mappings and then NFC.
0186  * See https://www.unicode.org/reports/tr44/#NFKC_Casefold
0187  *
0188  * Same as unorm2_getInstance(NULL, "nfkc_cf", UNORM2_COMPOSE, pErrorCode).
0189  * Returns an unmodifiable singleton instance. Do not delete it.
0190  * @param pErrorCode Standard ICU error code. Its input value must
0191  *                  pass the U_SUCCESS() test, or else the function returns
0192  *                  immediately. Check for U_FAILURE() on output or use with
0193  *                  function chaining. (See User Guide for details.)
0194  * @return the requested Normalizer2, if successful
0195  * @stable ICU 49
0196  */
0197 U_CAPI const UNormalizer2 * U_EXPORT2
0198 unorm2_getNFKCCasefoldInstance(UErrorCode *pErrorCode);
0199 
0200 #ifndef U_HIDE_DRAFT_API
0201 /**
0202  * Returns a UNormalizer2 instance for a variant of Unicode toNFKC_Casefold() normalization
0203  * which is equivalent to applying the NFKC_Simple_Casefold mappings and then NFC.
0204  * See https://www.unicode.org/reports/tr44/#NFKC_Simple_Casefold
0205  *
0206  * Same as unorm2_getInstance(NULL, "nfkc_scf", UNORM2_COMPOSE, pErrorCode).
0207  * Returns an unmodifiable singleton instance. Do not delete it.
0208  * @param pErrorCode Standard ICU error code. Its input value must
0209  *                  pass the U_SUCCESS() test, or else the function returns
0210  *                  immediately. Check for U_FAILURE() on output or use with
0211  *                  function chaining. (See User Guide for details.)
0212  * @return the requested Normalizer2, if successful
0213  * @draft ICU 74
0214  */
0215 U_CAPI const UNormalizer2 * U_EXPORT2
0216 unorm2_getNFKCSimpleCasefoldInstance(UErrorCode *pErrorCode);
0217 #endif  // U_HIDE_DRAFT_API
0218 
0219 /**
0220  * Returns a UNormalizer2 instance which uses the specified data file
0221  * (packageName/name similar to ucnv_openPackage() and ures_open()/ResourceBundle)
0222  * and which composes or decomposes text according to the specified mode.
0223  * Returns an unmodifiable singleton instance. Do not delete it.
0224  *
0225  * Use packageName=NULL for data files that are part of ICU's own data.
0226  * Use name="nfc" and UNORM2_COMPOSE/UNORM2_DECOMPOSE for Unicode standard NFC/NFD.
0227  * Use name="nfkc" and UNORM2_COMPOSE/UNORM2_DECOMPOSE for Unicode standard NFKC/NFKD.
0228  * Use name="nfkc_cf" and UNORM2_COMPOSE for Unicode standard NFKC_CF=NFKC_Casefold.
0229  *
0230  * @param packageName NULL for ICU built-in data, otherwise application data package name
0231  * @param name "nfc" or "nfkc" or "nfkc_cf" or "nfkc_scf" or name of custom data file
0232  * @param mode normalization mode (compose or decompose etc.)
0233  * @param pErrorCode Standard ICU error code. Its input value must
0234  *                  pass the U_SUCCESS() test, or else the function returns
0235  *                  immediately. Check for U_FAILURE() on output or use with
0236  *                  function chaining. (See User Guide for details.)
0237  * @return the requested UNormalizer2, if successful
0238  * @stable ICU 4.4
0239  */
0240 U_CAPI const UNormalizer2 * U_EXPORT2
0241 unorm2_getInstance(const char *packageName,
0242                    const char *name,
0243                    UNormalization2Mode mode,
0244                    UErrorCode *pErrorCode);
0245 
0246 /**
0247  * Constructs a filtered normalizer wrapping any UNormalizer2 instance
0248  * and a filter set.
0249  * Both are aliased and must not be modified or deleted while this object
0250  * is used.
0251  * The filter set should be frozen; otherwise the performance will suffer greatly.
0252  * @param norm2 wrapped UNormalizer2 instance
0253  * @param filterSet USet which determines the characters to be normalized
0254  * @param pErrorCode Standard ICU error code. Its input value must
0255  *                   pass the U_SUCCESS() test, or else the function returns
0256  *                   immediately. Check for U_FAILURE() on output or use with
0257  *                   function chaining. (See User Guide for details.)
0258  * @return the requested UNormalizer2, if successful
0259  * @stable ICU 4.4
0260  */
0261 U_CAPI UNormalizer2 * U_EXPORT2
0262 unorm2_openFiltered(const UNormalizer2 *norm2, const USet *filterSet, UErrorCode *pErrorCode);
0263 
0264 /**
0265  * Closes a UNormalizer2 instance from unorm2_openFiltered().
0266  * Do not close instances from unorm2_getInstance()!
0267  * @param norm2 UNormalizer2 instance to be closed
0268  * @stable ICU 4.4
0269  */
0270 U_CAPI void U_EXPORT2
0271 unorm2_close(UNormalizer2 *norm2);
0272 
0273 #if U_SHOW_CPLUSPLUS_API
0274 
0275 U_NAMESPACE_BEGIN
0276 
0277 /**
0278  * \class LocalUNormalizer2Pointer
0279  * "Smart pointer" class, closes a UNormalizer2 via unorm2_close().
0280  * For most methods see the LocalPointerBase base class.
0281  *
0282  * @see LocalPointerBase
0283  * @see LocalPointer
0284  * @stable ICU 4.4
0285  */
0286 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNormalizer2Pointer, UNormalizer2, unorm2_close);
0287 
0288 U_NAMESPACE_END
0289 
0290 #endif
0291 
0292 /**
0293  * Writes the normalized form of the source string to the destination string
0294  * (replacing its contents) and returns the length of the destination string.
0295  * The source and destination strings must be different buffers.
0296  * @param norm2 UNormalizer2 instance
0297  * @param src source string
0298  * @param length length of the source string, or -1 if NUL-terminated
0299  * @param dest destination string; its contents is replaced with normalized src
0300  * @param capacity number of UChars that can be written to dest
0301  * @param pErrorCode Standard ICU error code. Its input value must
0302  *                   pass the U_SUCCESS() test, or else the function returns
0303  *                   immediately. Check for U_FAILURE() on output or use with
0304  *                   function chaining. (See User Guide for details.)
0305  * @return dest
0306  * @stable ICU 4.4
0307  */
0308 U_CAPI int32_t U_EXPORT2
0309 unorm2_normalize(const UNormalizer2 *norm2,
0310                  const UChar *src, int32_t length,
0311                  UChar *dest, int32_t capacity,
0312                  UErrorCode *pErrorCode);
0313 /**
0314  * Appends the normalized form of the second string to the first string
0315  * (merging them at the boundary) and returns the length of the first string.
0316  * The result is normalized if the first string was normalized.
0317  * The first and second strings must be different buffers.
0318  * @param norm2 UNormalizer2 instance
0319  * @param first string, should be normalized
0320  * @param firstLength length of the first string, or -1 if NUL-terminated
0321  * @param firstCapacity number of UChars that can be written to first
0322  * @param second string, will be normalized
0323  * @param secondLength length of the source string, or -1 if NUL-terminated
0324  * @param pErrorCode Standard ICU error code. Its input value must
0325  *                   pass the U_SUCCESS() test, or else the function returns
0326  *                   immediately. Check for U_FAILURE() on output or use with
0327  *                   function chaining. (See User Guide for details.)
0328  * @return first
0329  * @stable ICU 4.4
0330  */
0331 U_CAPI int32_t U_EXPORT2
0332 unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,
0333                                 UChar *first, int32_t firstLength, int32_t firstCapacity,
0334                                 const UChar *second, int32_t secondLength,
0335                                 UErrorCode *pErrorCode);
0336 /**
0337  * Appends the second string to the first string
0338  * (merging them at the boundary) and returns the length of the first string.
0339  * The result is normalized if both the strings were normalized.
0340  * The first and second strings must be different buffers.
0341  * @param norm2 UNormalizer2 instance
0342  * @param first string, should be normalized
0343  * @param firstLength length of the first string, or -1 if NUL-terminated
0344  * @param firstCapacity number of UChars that can be written to first
0345  * @param second string, should be normalized
0346  * @param secondLength length of the source string, or -1 if NUL-terminated
0347  * @param pErrorCode Standard ICU error code. Its input value must
0348  *                   pass the U_SUCCESS() test, or else the function returns
0349  *                   immediately. Check for U_FAILURE() on output or use with
0350  *                   function chaining. (See User Guide for details.)
0351  * @return first
0352  * @stable ICU 4.4
0353  */
0354 U_CAPI int32_t U_EXPORT2
0355 unorm2_append(const UNormalizer2 *norm2,
0356               UChar *first, int32_t firstLength, int32_t firstCapacity,
0357               const UChar *second, int32_t secondLength,
0358               UErrorCode *pErrorCode);
0359 
0360 /**
0361  * Gets the decomposition mapping of c.
0362  * Roughly equivalent to normalizing the String form of c
0363  * on a UNORM2_DECOMPOSE UNormalizer2 instance, but much faster, and except that this function
0364  * returns a negative value and does not write a string
0365  * if c does not have a decomposition mapping in this instance's data.
0366  * This function is independent of the mode of the UNormalizer2.
0367  * @param norm2 UNormalizer2 instance
0368  * @param c code point
0369  * @param decomposition String buffer which will be set to c's
0370  *                      decomposition mapping, if there is one.
0371  * @param capacity number of UChars that can be written to decomposition
0372  * @param pErrorCode Standard ICU error code. Its input value must
0373  *                   pass the U_SUCCESS() test, or else the function returns
0374  *                   immediately. Check for U_FAILURE() on output or use with
0375  *                   function chaining. (See User Guide for details.)
0376  * @return the non-negative length of c's decomposition, if there is one; otherwise a negative value
0377  * @stable ICU 4.6
0378  */
0379 U_CAPI int32_t U_EXPORT2
0380 unorm2_getDecomposition(const UNormalizer2 *norm2,
0381                         UChar32 c, UChar *decomposition, int32_t capacity,
0382                         UErrorCode *pErrorCode);
0383 
0384 /**
0385  * Gets the raw decomposition mapping of c.
0386  *
0387  * This is similar to the unorm2_getDecomposition() function but returns the
0388  * raw decomposition mapping as specified in UnicodeData.txt or
0389  * (for custom data) in the mapping files processed by the gennorm2 tool.
0390  * By contrast, unorm2_getDecomposition() returns the processed,
0391  * recursively-decomposed version of this mapping.
0392  *
0393  * When used on a standard NFKC Normalizer2 instance,
0394  * unorm2_getRawDecomposition() returns the Unicode Decomposition_Mapping (dm) property.
0395  *
0396  * When used on a standard NFC Normalizer2 instance,
0397  * it returns the Decomposition_Mapping only if the Decomposition_Type (dt) is Canonical (Can);
0398  * in this case, the result contains either one or two code points (=1..4 UChars).
0399  *
0400  * This function is independent of the mode of the UNormalizer2.
0401  * @param norm2 UNormalizer2 instance
0402  * @param c code point
0403  * @param decomposition String buffer which will be set to c's
0404  *                      raw decomposition mapping, if there is one.
0405  * @param capacity number of UChars that can be written to decomposition
0406  * @param pErrorCode Standard ICU error code. Its input value must
0407  *                   pass the U_SUCCESS() test, or else the function returns
0408  *                   immediately. Check for U_FAILURE() on output or use with
0409  *                   function chaining. (See User Guide for details.)
0410  * @return the non-negative length of c's raw decomposition, if there is one; otherwise a negative value
0411  * @stable ICU 49
0412  */
0413 U_CAPI int32_t U_EXPORT2
0414 unorm2_getRawDecomposition(const UNormalizer2 *norm2,
0415                            UChar32 c, UChar *decomposition, int32_t capacity,
0416                            UErrorCode *pErrorCode);
0417 
0418 /**
0419  * Performs pairwise composition of a & b and returns the composite if there is one.
0420  *
0421  * Returns a composite code point c only if c has a two-way mapping to a+b.
0422  * In standard Unicode normalization, this means that
0423  * c has a canonical decomposition to a+b
0424  * and c does not have the Full_Composition_Exclusion property.
0425  *
0426  * This function is independent of the mode of the UNormalizer2.
0427  * @param norm2 UNormalizer2 instance
0428  * @param a A (normalization starter) code point.
0429  * @param b Another code point.
0430  * @return The non-negative composite code point if there is one; otherwise a negative value.
0431  * @stable ICU 49
0432  */
0433 U_CAPI UChar32 U_EXPORT2
0434 unorm2_composePair(const UNormalizer2 *norm2, UChar32 a, UChar32 b);
0435 
0436 /**
0437  * Gets the combining class of c.
0438  * The default implementation returns 0
0439  * but all standard implementations return the Unicode Canonical_Combining_Class value.
0440  * @param norm2 UNormalizer2 instance
0441  * @param c code point
0442  * @return c's combining class
0443  * @stable ICU 49
0444  */
0445 U_CAPI uint8_t U_EXPORT2
0446 unorm2_getCombiningClass(const UNormalizer2 *norm2, UChar32 c);
0447 
0448 /**
0449  * Tests if the string is normalized.
0450  * Internally, in cases where the quickCheck() method would return "maybe"
0451  * (which is only possible for the two COMPOSE modes) this method
0452  * resolves to "yes" or "no" to provide a definitive result,
0453  * at the cost of doing more work in those cases.
0454  * @param norm2 UNormalizer2 instance
0455  * @param s input string
0456  * @param length length of the string, or -1 if NUL-terminated
0457  * @param pErrorCode Standard ICU error code. Its input value must
0458  *                   pass the U_SUCCESS() test, or else the function returns
0459  *                   immediately. Check for U_FAILURE() on output or use with
0460  *                   function chaining. (See User Guide for details.)
0461  * @return true if s is normalized
0462  * @stable ICU 4.4
0463  */
0464 U_CAPI UBool U_EXPORT2
0465 unorm2_isNormalized(const UNormalizer2 *norm2,
0466                     const UChar *s, int32_t length,
0467                     UErrorCode *pErrorCode);
0468 
0469 /**
0470  * Tests if the string is normalized.
0471  * For the two COMPOSE modes, the result could be "maybe" in cases that
0472  * would take a little more work to resolve definitively.
0473  * Use spanQuickCheckYes() and normalizeSecondAndAppend() for a faster
0474  * combination of quick check + normalization, to avoid
0475  * re-checking the "yes" prefix.
0476  * @param norm2 UNormalizer2 instance
0477  * @param s input string
0478  * @param length length of the string, or -1 if NUL-terminated
0479  * @param pErrorCode Standard ICU error code. Its input value must
0480  *                   pass the U_SUCCESS() test, or else the function returns
0481  *                   immediately. Check for U_FAILURE() on output or use with
0482  *                   function chaining. (See User Guide for details.)
0483  * @return UNormalizationCheckResult
0484  * @stable ICU 4.4
0485  */
0486 U_CAPI UNormalizationCheckResult U_EXPORT2
0487 unorm2_quickCheck(const UNormalizer2 *norm2,
0488                   const UChar *s, int32_t length,
0489                   UErrorCode *pErrorCode);
0490 
0491 /**
0492  * Returns the end of the normalized substring of the input string.
0493  * In other words, with <code>end=spanQuickCheckYes(s, ec);</code>
0494  * the substring <code>UnicodeString(s, 0, end)</code>
0495  * will pass the quick check with a "yes" result.
0496  *
0497  * The returned end index is usually one or more characters before the
0498  * "no" or "maybe" character: The end index is at a normalization boundary.
0499  * (See the class documentation for more about normalization boundaries.)
0500  *
0501  * When the goal is a normalized string and most input strings are expected
0502  * to be normalized already, then call this method,
0503  * and if it returns a prefix shorter than the input string,
0504  * copy that prefix and use normalizeSecondAndAppend() for the remainder.
0505  * @param norm2 UNormalizer2 instance
0506  * @param s input string
0507  * @param length length of the string, or -1 if NUL-terminated
0508  * @param pErrorCode Standard ICU error code. Its input value must
0509  *                   pass the U_SUCCESS() test, or else the function returns
0510  *                   immediately. Check for U_FAILURE() on output or use with
0511  *                   function chaining. (See User Guide for details.)
0512  * @return "yes" span end index
0513  * @stable ICU 4.4
0514  */
0515 U_CAPI int32_t U_EXPORT2
0516 unorm2_spanQuickCheckYes(const UNormalizer2 *norm2,
0517                          const UChar *s, int32_t length,
0518                          UErrorCode *pErrorCode);
0519 
0520 /**
0521  * Tests if the character always has a normalization boundary before it,
0522  * regardless of context.
0523  * For details see the Normalizer2 base class documentation.
0524  * @param norm2 UNormalizer2 instance
0525  * @param c character to test
0526  * @return true if c has a normalization boundary before it
0527  * @stable ICU 4.4
0528  */
0529 U_CAPI UBool U_EXPORT2
0530 unorm2_hasBoundaryBefore(const UNormalizer2 *norm2, UChar32 c);
0531 
0532 /**
0533  * Tests if the character always has a normalization boundary after it,
0534  * regardless of context.
0535  * For details see the Normalizer2 base class documentation.
0536  * @param norm2 UNormalizer2 instance
0537  * @param c character to test
0538  * @return true if c has a normalization boundary after it
0539  * @stable ICU 4.4
0540  */
0541 U_CAPI UBool U_EXPORT2
0542 unorm2_hasBoundaryAfter(const UNormalizer2 *norm2, UChar32 c);
0543 
0544 /**
0545  * Tests if the character is normalization-inert.
0546  * For details see the Normalizer2 base class documentation.
0547  * @param norm2 UNormalizer2 instance
0548  * @param c character to test
0549  * @return true if c is normalization-inert
0550  * @stable ICU 4.4
0551  */
0552 U_CAPI UBool U_EXPORT2
0553 unorm2_isInert(const UNormalizer2 *norm2, UChar32 c);
0554 
0555 /**
0556  * Compares two strings for canonical equivalence.
0557  * Further options include case-insensitive comparison and
0558  * code point order (as opposed to code unit order).
0559  *
0560  * Canonical equivalence between two strings is defined as their normalized
0561  * forms (NFD or NFC) being identical.
0562  * This function compares strings incrementally instead of normalizing
0563  * (and optionally case-folding) both strings entirely,
0564  * improving performance significantly.
0565  *
0566  * Bulk normalization is only necessary if the strings do not fulfill the FCD
0567  * conditions. Only in this case, and only if the strings are relatively long,
0568  * is memory allocated temporarily.
0569  * For FCD strings and short non-FCD strings there is no memory allocation.
0570  *
0571  * Semantically, this is equivalent to
0572  *   strcmp[CodePointOrder](NFD(foldCase(NFD(s1))), NFD(foldCase(NFD(s2))))
0573  * where code point order and foldCase are all optional.
0574  *
0575  * UAX 21 2.5 Caseless Matching specifies that for a canonical caseless match
0576  * the case folding must be performed first, then the normalization.
0577  *
0578  * @param s1 First source string.
0579  * @param length1 Length of first source string, or -1 if NUL-terminated.
0580  *
0581  * @param s2 Second source string.
0582  * @param length2 Length of second source string, or -1 if NUL-terminated.
0583  *
0584  * @param options A bit set of options:
0585  *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
0586  *     Case-sensitive comparison in code unit order, and the input strings
0587  *     are quick-checked for FCD.
0588  *
0589  *   - UNORM_INPUT_IS_FCD
0590  *     Set if the caller knows that both s1 and s2 fulfill the FCD conditions.
0591  *     If not set, the function will quickCheck for FCD
0592  *     and normalize if necessary.
0593  *
0594  *   - U_COMPARE_CODE_POINT_ORDER
0595  *     Set to choose code point order instead of code unit order
0596  *     (see u_strCompare for details).
0597  *
0598  *   - U_COMPARE_IGNORE_CASE
0599  *     Set to compare strings case-insensitively using case folding,
0600  *     instead of case-sensitively.
0601  *     If set, then the following case folding options are used.
0602  *
0603  *   - Options as used with case-insensitive comparisons, currently:
0604  *
0605  *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
0606  *    (see u_strCaseCompare for details)
0607  *
0608  *   - regular normalization options shifted left by UNORM_COMPARE_NORM_OPTIONS_SHIFT
0609  *
0610  * @param pErrorCode ICU error code in/out parameter.
0611  *                   Must fulfill U_SUCCESS before the function call.
0612  * @return <0 or 0 or >0 as usual for string comparisons
0613  *
0614  * @see unorm_normalize
0615  * @see UNORM_FCD
0616  * @see u_strCompare
0617  * @see u_strCaseCompare
0618  *
0619  * @stable ICU 2.2
0620  */
0621 U_CAPI int32_t U_EXPORT2
0622 unorm_compare(const UChar *s1, int32_t length1,
0623               const UChar *s2, int32_t length2,
0624               uint32_t options,
0625               UErrorCode *pErrorCode);
0626 
0627 #endif  /* !UCONFIG_NO_NORMALIZATION */
0628 #endif  /* __UNORM2_H__ */