unorm2.h 25 KB

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