Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: public/i18n/unicode/ucol.h

Issue 18836004: Move ICU headers from public/{common,i18n} to source/{common,i18n} (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu46.git@master
Patch Set: same as ps #3. retry uploading Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « public/i18n/unicode/ucal.h ('k') | public/i18n/unicode/ucoleitr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 *******************************************************************************
3 * Copyright (c) 1996-2010, International Business Machines Corporation and other s.
4 * All Rights Reserved.
5 *******************************************************************************
6 */
7
8 #ifndef UCOL_H
9 #define UCOL_H
10
11 #include "unicode/utypes.h"
12
13 #if !UCONFIG_NO_COLLATION
14
15 #include "unicode/unorm.h"
16 #include "unicode/localpointer.h"
17 #include "unicode/parseerr.h"
18 #include "unicode/uloc.h"
19 #include "unicode/uset.h"
20
21 /**
22 * \file
23 * \brief C API: Collator
24 *
25 * <h2> Collator C API </h2>
26 *
27 * The C API for Collator performs locale-sensitive
28 * string comparison. You use this service to build
29 * searching and sorting routines for natural language text.
30 * <em>Important: </em>The ICU collation service has been reimplemented
31 * in order to achieve better performance and UCA compliance.
32 * For details, see the
33 * <a href="http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collati on/ICU_collation_design.htm">
34 * collation design document</a>.
35 * <p>
36 * For more information about the collation service see
37 * <a href="http://icu-project.org/userguide/Collate_Intro.html">the users guide </a>.
38 * <p>
39 * Collation service provides correct sorting orders for most locales supported in ICU.
40 * If specific data for a locale is not available, the orders eventually falls b ack
41 * to the <a href="http://www.unicode.org/unicode/reports/tr10/">UCA sort order< /a>.
42 * <p>
43 * Sort ordering may be customized by providing your own set of rules. For more on
44 * this subject see the
45 * <a href="http://icu-project.org/userguide/Collate_Customization.html">
46 * Collation customization</a> section of the users guide.
47 * <p>
48 * @see UCollationResult
49 * @see UNormalizationMode
50 * @see UCollationStrength
51 * @see UCollationElements
52 */
53
54 /** A collator.
55 * For usage in C programs.
56 */
57 struct UCollator;
58 /** structure representing a collator object instance
59 * @stable ICU 2.0
60 */
61 typedef struct UCollator UCollator;
62
63
64 /**
65 * UCOL_LESS is returned if source string is compared to be less than target
66 * string in the u_strcoll() method.
67 * UCOL_EQUAL is returned if source string is compared to be equal to target
68 * string in the u_strcoll() method.
69 * UCOL_GREATER is returned if source string is compared to be greater than
70 * target string in the u_strcoll() method.
71 * @see u_strcoll()
72 * <p>
73 * Possible values for a comparison result
74 * @stable ICU 2.0
75 */
76 typedef enum {
77 /** string a == string b */
78 UCOL_EQUAL = 0,
79 /** string a > string b */
80 UCOL_GREATER = 1,
81 /** string a < string b */
82 UCOL_LESS = -1
83 } UCollationResult ;
84
85
86 /** Enum containing attribute values for controling collation behavior.
87 * Here are all the allowable values. Not every attribute can take every value. The only
88 * universal value is UCOL_DEFAULT, which resets the attribute value to the pred efined
89 * value for that locale
90 * @stable ICU 2.0
91 */
92 typedef enum {
93 /** accepted by most attributes */
94 UCOL_DEFAULT = -1,
95
96 /** Primary collation strength */
97 UCOL_PRIMARY = 0,
98 /** Secondary collation strength */
99 UCOL_SECONDARY = 1,
100 /** Tertiary collation strength */
101 UCOL_TERTIARY = 2,
102 /** Default collation strength */
103 UCOL_DEFAULT_STRENGTH = UCOL_TERTIARY,
104 UCOL_CE_STRENGTH_LIMIT,
105 /** Quaternary collation strength */
106 UCOL_QUATERNARY=3,
107 /** Identical collation strength */
108 UCOL_IDENTICAL=15,
109 UCOL_STRENGTH_LIMIT,
110
111 /** Turn the feature off - works for UCOL_FRENCH_COLLATION,
112 UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE
113 & UCOL_DECOMPOSITION_MODE*/
114 UCOL_OFF = 16,
115 /** Turn the feature on - works for UCOL_FRENCH_COLLATION,
116 UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE
117 & UCOL_DECOMPOSITION_MODE*/
118 UCOL_ON = 17,
119
120 /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be shifted */
121 UCOL_SHIFTED = 20,
122 /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be non ignorabl e */
123 UCOL_NON_IGNORABLE = 21,
124
125 /** Valid for UCOL_CASE_FIRST -
126 lower case sorts before upper case */
127 UCOL_LOWER_FIRST = 24,
128 /** upper case sorts before lower case */
129 UCOL_UPPER_FIRST = 25,
130
131 UCOL_ATTRIBUTE_VALUE_COUNT
132
133 } UColAttributeValue;
134
135 /** Enum containing the codes for reordering segments of the collation table tha t are not script
136 * codes. These reordering codes are to be used in conjunction with the script codes.
137 * @internal
138 */
139 typedef enum {
140 UCOL_REORDER_CODE_SPACE = 0x1000,
141 UCOL_REORDER_CODE_FIRST = UCOL_REORDER_CODE_SPACE,
142 UCOL_REORDER_CODE_PUNCTUATION = 0x1001,
143 UCOL_REORDER_CODE_SYMBOL = 0x1002,
144 UCOL_REORDER_CODE_CURRENCY = 0x1003,
145 UCOL_REORDER_CODE_DIGIT = 0x1004,
146 UCOL_REORDER_CODE_LIMIT = 0x1005
147 } UColReorderCode;
148
149 /**
150 * Base letter represents a primary difference. Set comparison
151 * level to UCOL_PRIMARY to ignore secondary and tertiary differences.
152 * Use this to set the strength of a Collator object.
153 * Example of primary difference, "abc" &lt; "abd"
154 *
155 * Diacritical differences on the same base letter represent a secondary
156 * difference. Set comparison level to UCOL_SECONDARY to ignore tertiary
157 * differences. Use this to set the strength of a Collator object.
158 * Example of secondary difference, "&auml;" >> "a".
159 *
160 * Uppercase and lowercase versions of the same character represents a
161 * tertiary difference. Set comparison level to UCOL_TERTIARY to include
162 * all comparison differences. Use this to set the strength of a Collator
163 * object.
164 * Example of tertiary difference, "abc" &lt;&lt;&lt; "ABC".
165 *
166 * Two characters are considered "identical" when they have the same
167 * unicode spellings. UCOL_IDENTICAL.
168 * For example, "&auml;" == "&auml;".
169 *
170 * UCollationStrength is also used to determine the strength of sort keys
171 * generated from UCollator objects
172 * These values can be now found in the UColAttributeValue enum.
173 * @stable ICU 2.0
174 **/
175 typedef UColAttributeValue UCollationStrength;
176
177 /** Attributes that collation service understands. All the attributes can take U COL_DEFAULT
178 * value, as well as the values specific to each one.
179 * @stable ICU 2.0
180 */
181 typedef enum {
182 /** Attribute for direction of secondary weights - used in French.
183 * Acceptable values are UCOL_ON, which results in secondary weights
184 * being considered backwards and UCOL_OFF which treats secondary
185 * weights in the order they appear.*/
186 UCOL_FRENCH_COLLATION,
187 /** Attribute for handling variable elements.
188 * Acceptable values are UCOL_NON_IGNORABLE (default)
189 * which treats all the codepoints with non-ignorable
190 * primary weights in the same way,
191 * and UCOL_SHIFTED which causes codepoints with primary
192 * weights that are equal or below the variable top value
193 * to be ignored on primary level and moved to the quaternary
194 * level.*/
195 UCOL_ALTERNATE_HANDLING,
196 /** Controls the ordering of upper and lower case letters.
197 * Acceptable values are UCOL_OFF (default), which orders
198 * upper and lower case letters in accordance to their tertiary
199 * weights, UCOL_UPPER_FIRST which forces upper case letters to
200 * sort before lower case letters, and UCOL_LOWER_FIRST which does
201 * the opposite. */
202 UCOL_CASE_FIRST,
203 /** Controls whether an extra case level (positioned before the third
204 * level) is generated or not. Acceptable values are UCOL_OFF (default),
205 * when case level is not generated, and UCOL_ON which causes the case
206 * level to be generated. Contents of the case level are affected by
207 * the value of UCOL_CASE_FIRST attribute. A simple way to ignore
208 * accent differences in a string is to set the strength to UCOL_PRIMARY
209 * and enable case level. */
210 UCOL_CASE_LEVEL,
211 /** Controls whether the normalization check and necessary normalizations
212 * are performed. When set to UCOL_OFF (default) no normalization check
213 * is performed. The correctness of the result is guaranteed only if the
214 * input data is in so-called FCD form (see users manual for more info).
215 * When set to UCOL_ON, an incremental check is performed to see whether
216 * the input data is in the FCD form. If the data is not in the FCD form,
217 * incremental NFD normalization is performed. */
218 UCOL_NORMALIZATION_MODE,
219 /** An alias for UCOL_NORMALIZATION_MODE attribute */
220 UCOL_DECOMPOSITION_MODE = UCOL_NORMALIZATION_MODE,
221 /** The strength attribute. Can be either UCOL_PRIMARY, UCOL_SECONDARY,
222 * UCOL_TERTIARY, UCOL_QUATERNARY or UCOL_IDENTICAL. The usual strength
223 * for most locales (except Japanese) is tertiary. Quaternary strength
224 * is useful when combined with shifted setting for alternate handling
225 * attribute and for JIS x 4061 collation, when it is used to distinguish
226 * between Katakana and Hiragana (this is achieved by setting the
227 * UCOL_HIRAGANA_QUATERNARY mode to on. Otherwise, quaternary level
228 * is affected only by the number of non ignorable code points in
229 * the string. Identical strength is rarely useful, as it amounts
230 * to codepoints of the NFD form of the string. */
231 UCOL_STRENGTH,
232 /** When turned on, this attribute positions Hiragana before all
233 * non-ignorables on quaternary level This is a sneaky way to produce JIS
234 * sort order */
235 UCOL_HIRAGANA_QUATERNARY_MODE,
236 /** When turned on, this attribute generates a collation key
237 * for the numeric value of substrings of digits.
238 * This is a way to get '100' to sort AFTER '2'. Note that the longest
239 * digit substring that can be treated as a single collation element is
240 * 254 digits (not counting leading zeros). If a digit substring is
241 * longer than that, the digits beyond the limit will be treated as a
242 * separate digit substring associated with a separate collation element. * /
243 UCOL_NUMERIC_COLLATION,
244 UCOL_ATTRIBUTE_COUNT
245 } UColAttribute;
246
247 /** Options for retrieving the rule string
248 * @stable ICU 2.0
249 */
250 typedef enum {
251 /** Retrieve tailoring only */
252 UCOL_TAILORING_ONLY,
253 /** Retrieve UCA rules and tailoring */
254 UCOL_FULL_RULES
255 } UColRuleOption ;
256
257 /**
258 * Open a UCollator for comparing strings.
259 * The UCollator pointer is used in all the calls to the Collation
260 * service. After finished, collator must be disposed of by calling
261 * {@link #ucol_close }.
262 * @param loc The locale containing the required collation rules.
263 * Special values for locales can be passed in -
264 * if NULL is passed for the locale, the default locale
265 * collation rules will be used. If empty string ("") or
266 * "root" are passed, UCA rules will be used.
267 * @param status A pointer to an UErrorCode to receive any errors
268 * @return A pointer to a UCollator, or 0 if an error occurred.
269 * @see ucol_openRules
270 * @see ucol_safeClone
271 * @see ucol_close
272 * @stable ICU 2.0
273 */
274 U_STABLE UCollator* U_EXPORT2
275 ucol_open(const char *loc, UErrorCode *status);
276
277 /**
278 * Produce an UCollator instance according to the rules supplied.
279 * The rules are used to change the default ordering, defined in the
280 * UCA in a process called tailoring. The resulting UCollator pointer
281 * can be used in the same way as the one obtained by {@link #ucol_strcoll }.
282 * @param rules A string describing the collation rules. For the syntax
283 * of the rules please see users guide.
284 * @param rulesLength The length of rules, or -1 if null-terminated.
285 * @param normalizationMode The normalization mode: One of
286 * UCOL_OFF (expect the text to not need normalization),
287 * UCOL_ON (normalize), or
288 * UCOL_DEFAULT (set the mode according to the rules)
289 * @param strength The default collation strength; one of UCOL_PRIMARY, UCOL_SEC ONDARY,
290 * UCOL_TERTIARY, UCOL_IDENTICAL,UCOL_DEFAULT_STRENGTH - can be also set in the rules.
291 * @param parseError A pointer to UParseError to recieve information about erro rs
292 * occurred during parsing. This argument can currently be se t
293 * to NULL, but at users own risk. Please provide a real stru cture.
294 * @param status A pointer to an UErrorCode to receive any errors
295 * @return A pointer to a UCollator. It is not guaranteed that NULL be returned in case
296 * of error - please use status argument to check for errors.
297 * @see ucol_open
298 * @see ucol_safeClone
299 * @see ucol_close
300 * @stable ICU 2.0
301 */
302 U_STABLE UCollator* U_EXPORT2
303 ucol_openRules( const UChar *rules,
304 int32_t rulesLength,
305 UColAttributeValue normalizationMode,
306 UCollationStrength strength,
307 UParseError *parseError,
308 UErrorCode *status);
309
310 /**
311 * Open a collator defined by a short form string.
312 * The structure and the syntax of the string is defined in the "Naming collator s"
313 * section of the users guide:
314 * http://icu-project.org/userguide/Collate_Concepts.html#Naming_Collators
315 * Attributes are overriden by the subsequent attributes. So, for "S2_S3", final
316 * strength will be 3. 3066bis locale overrides individual locale parts.
317 * The call to this function is equivalent to a call to ucol_open, followed by a
318 * series of calls to ucol_setAttribute and ucol_setVariableTop.
319 * @param definition A short string containing a locale and a set of attributes.
320 * Attributes not explicitly mentioned are left at the default
321 * state for a locale.
322 * @param parseError if not NULL, structure that will get filled with error's pr e
323 * and post context in case of error.
324 * @param forceDefaults if FALSE, the settings that are the same as the collator
325 * default settings will not be applied (for example, setting
326 * French secondary on a French collator would not be executed ).
327 * If TRUE, all the settings will be applied regardless of the
328 * collator default value. If the definition
329 * strings are to be cached, should be set to FALSE.
330 * @param status Error code. Apart from regular error conditions connected t o
331 * instantiating collators (like out of memory or similar), th is
332 * API will return an error if an invalid attribute or attribu te/value
333 * combination is specified.
334 * @return A pointer to a UCollator or 0 if an error occured (includin g an
335 * invalid attribute).
336 * @see ucol_open
337 * @see ucol_setAttribute
338 * @see ucol_setVariableTop
339 * @see ucol_getShortDefinitionString
340 * @see ucol_normalizeShortDefinitionString
341 * @stable ICU 3.0
342 *
343 */
344 U_STABLE UCollator* U_EXPORT2
345 ucol_openFromShortString( const char *definition,
346 UBool forceDefaults,
347 UParseError *parseError,
348 UErrorCode *status);
349
350 /**
351 * Get a set containing the contractions defined by the collator. The set includ es
352 * both the UCA contractions and the contractions defined by the collator. This set
353 * will contain only strings. If a tailoring explicitly suppresses contractions from
354 * the UCA (like Russian), removed contractions will not be in the resulting set .
355 * @param coll collator
356 * @param conts the set to hold the result. It gets emptied before
357 * contractions are added.
358 * @param status to hold the error code
359 * @return the size of the contraction set
360 *
361 * @deprecated ICU 3.4, use ucol_getContractionsAndExpansions instead
362 */
363 U_DEPRECATED int32_t U_EXPORT2
364 ucol_getContractions( const UCollator *coll,
365 USet *conts,
366 UErrorCode *status);
367
368 /**
369 * Get a set containing the expansions defined by the collator. The set includes
370 * both the UCA expansions and the expansions defined by the tailoring
371 * @param coll collator
372 * @param contractions if not NULL, the set to hold the contractions
373 * @param expansions if not NULL, the set to hold the expansions
374 * @param addPrefixes add the prefix contextual elements to contractions
375 * @param status to hold the error code
376 *
377 * @stable ICU 3.4
378 */
379 U_STABLE void U_EXPORT2
380 ucol_getContractionsAndExpansions( const UCollator *coll,
381 USet *contractions, USet *expansions,
382 UBool addPrefixes, UErrorCode *status);
383
384 /**
385 * Close a UCollator.
386 * Once closed, a UCollator should not be used. Every open collator should
387 * be closed. Otherwise, a memory leak will result.
388 * @param coll The UCollator to close.
389 * @see ucol_open
390 * @see ucol_openRules
391 * @see ucol_safeClone
392 * @stable ICU 2.0
393 */
394 U_STABLE void U_EXPORT2
395 ucol_close(UCollator *coll);
396
397 #if U_SHOW_CPLUSPLUS_API
398
399 U_NAMESPACE_BEGIN
400
401 /**
402 * \class LocalUCollatorPointer
403 * "Smart pointer" class, closes a UCollator via ucol_close().
404 * For most methods see the LocalPointerBase base class.
405 *
406 * @see LocalPointerBase
407 * @see LocalPointer
408 * @stable ICU 4.4
409 */
410 U_DEFINE_LOCAL_OPEN_POINTER(LocalUCollatorPointer, UCollator, ucol_close);
411
412 U_NAMESPACE_END
413
414 #endif
415
416 /**
417 * Compare two strings.
418 * The strings will be compared using the options already specified.
419 * @param coll The UCollator containing the comparison rules.
420 * @param source The source string.
421 * @param sourceLength The length of source, or -1 if null-terminated.
422 * @param target The target string.
423 * @param targetLength The length of target, or -1 if null-terminated.
424 * @return The result of comparing the strings; one of UCOL_EQUAL,
425 * UCOL_GREATER, UCOL_LESS
426 * @see ucol_greater
427 * @see ucol_greaterOrEqual
428 * @see ucol_equal
429 * @stable ICU 2.0
430 */
431 U_STABLE UCollationResult U_EXPORT2
432 ucol_strcoll( const UCollator *coll,
433 const UChar *source,
434 int32_t sourceLength,
435 const UChar *target,
436 int32_t targetLength);
437
438 /**
439 * Determine if one string is greater than another.
440 * This function is equivalent to {@link #ucol_strcoll } == UCOL_GREATER
441 * @param coll The UCollator containing the comparison rules.
442 * @param source The source string.
443 * @param sourceLength The length of source, or -1 if null-terminated.
444 * @param target The target string.
445 * @param targetLength The length of target, or -1 if null-terminated.
446 * @return TRUE if source is greater than target, FALSE otherwise.
447 * @see ucol_strcoll
448 * @see ucol_greaterOrEqual
449 * @see ucol_equal
450 * @stable ICU 2.0
451 */
452 U_STABLE UBool U_EXPORT2
453 ucol_greater(const UCollator *coll,
454 const UChar *source, int32_t sourceLength,
455 const UChar *target, int32_t targetLength);
456
457 /**
458 * Determine if one string is greater than or equal to another.
459 * This function is equivalent to {@link #ucol_strcoll } != UCOL_LESS
460 * @param coll The UCollator containing the comparison rules.
461 * @param source The source string.
462 * @param sourceLength The length of source, or -1 if null-terminated.
463 * @param target The target string.
464 * @param targetLength The length of target, or -1 if null-terminated.
465 * @return TRUE if source is greater than or equal to target, FALSE otherwise.
466 * @see ucol_strcoll
467 * @see ucol_greater
468 * @see ucol_equal
469 * @stable ICU 2.0
470 */
471 U_STABLE UBool U_EXPORT2
472 ucol_greaterOrEqual(const UCollator *coll,
473 const UChar *source, int32_t sourceLength,
474 const UChar *target, int32_t targetLength);
475
476 /**
477 * Compare two strings for equality.
478 * This function is equivalent to {@link #ucol_strcoll } == UCOL_EQUAL
479 * @param coll The UCollator containing the comparison rules.
480 * @param source The source string.
481 * @param sourceLength The length of source, or -1 if null-terminated.
482 * @param target The target string.
483 * @param targetLength The length of target, or -1 if null-terminated.
484 * @return TRUE if source is equal to target, FALSE otherwise
485 * @see ucol_strcoll
486 * @see ucol_greater
487 * @see ucol_greaterOrEqual
488 * @stable ICU 2.0
489 */
490 U_STABLE UBool U_EXPORT2
491 ucol_equal(const UCollator *coll,
492 const UChar *source, int32_t sourceLength,
493 const UChar *target, int32_t targetLength);
494
495 /**
496 * Compare two UTF-8 encoded trings.
497 * The strings will be compared using the options already specified.
498 * @param coll The UCollator containing the comparison rules.
499 * @param sIter The source string iterator.
500 * @param tIter The target string iterator.
501 * @return The result of comparing the strings; one of UCOL_EQUAL,
502 * UCOL_GREATER, UCOL_LESS
503 * @param status A pointer to an UErrorCode to receive any errors
504 * @see ucol_strcoll
505 * @stable ICU 2.6
506 */
507 U_STABLE UCollationResult U_EXPORT2
508 ucol_strcollIter( const UCollator *coll,
509 UCharIterator *sIter,
510 UCharIterator *tIter,
511 UErrorCode *status);
512
513 /**
514 * Get the collation strength used in a UCollator.
515 * The strength influences how strings are compared.
516 * @param coll The UCollator to query.
517 * @return The collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY,
518 * UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL
519 * @see ucol_setStrength
520 * @stable ICU 2.0
521 */
522 U_STABLE UCollationStrength U_EXPORT2
523 ucol_getStrength(const UCollator *coll);
524
525 /**
526 * Set the collation strength used in a UCollator.
527 * The strength influences how strings are compared.
528 * @param coll The UCollator to set.
529 * @param strength The desired collation strength; one of UCOL_PRIMARY,
530 * UCOL_SECONDARY, UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL, UCOL_DEFAULT
531 * @see ucol_getStrength
532 * @stable ICU 2.0
533 */
534 U_STABLE void U_EXPORT2
535 ucol_setStrength(UCollator *coll,
536 UCollationStrength strength);
537
538 /**
539 * Get the current reordering of scripts (if one has been set).
540 * @param coll The UCollator to query.
541 * @param dest The array to fill with the script ordering.
542 * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function will only return the length of the result without writing any of t he result string (pre-flighting).
543 * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a failure before the function call.
544 * @return The length of the array of the script ordering.
545 * @see ucol_setReorderCodes
546 * @internal
547 */
548 U_INTERNAL int32_t U_EXPORT2
549 ucol_getReorderCodes(const UCollator* coll,
550 int32_t* dest,
551 int32_t destCapacity,
552 UErrorCode *pErrorCode);
553
554 /**
555 * Set the ordering of scripts for this collator.
556 * @param coll The UCollator to set.
557 * @param reorderCodes An array of script codes in the new order.
558 * @param reorderCodesLength The length of reorderCodes.
559 * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a failure before the function call.
560 * @see ucol_getReorderCodes
561 * @internal
562 */
563 U_INTERNAL void U_EXPORT2
564 ucol_setReorderCodes(UCollator* coll,
565 const int32_t* reorderCodes,
566 int32_t reorderCodesLength,
567 UErrorCode *pErrorCode);
568
569 /**
570 * Get the display name for a UCollator.
571 * The display name is suitable for presentation to a user.
572 * @param objLoc The locale of the collator in question.
573 * @param dispLoc The locale for display.
574 * @param result A pointer to a buffer to receive the attribute.
575 * @param resultLength The maximum size of result.
576 * @param status A pointer to an UErrorCode to receive any errors
577 * @return The total buffer size needed; if greater than resultLength,
578 * the output was truncated.
579 * @stable ICU 2.0
580 */
581 U_STABLE int32_t U_EXPORT2
582 ucol_getDisplayName( const char *objLoc,
583 const char *dispLoc,
584 UChar *result,
585 int32_t resultLength,
586 UErrorCode *status);
587
588 /**
589 * Get a locale for which collation rules are available.
590 * A UCollator in a locale returned by this function will perform the correct
591 * collation for the locale.
592 * @param localeIndex The index of the desired locale.
593 * @return A locale for which collation rules are available, or 0 if none.
594 * @see ucol_countAvailable
595 * @stable ICU 2.0
596 */
597 U_STABLE const char* U_EXPORT2
598 ucol_getAvailable(int32_t localeIndex);
599
600 /**
601 * Determine how many locales have collation rules available.
602 * This function is most useful as determining the loop ending condition for
603 * calls to {@link #ucol_getAvailable }.
604 * @return The number of locales for which collation rules are available.
605 * @see ucol_getAvailable
606 * @stable ICU 2.0
607 */
608 U_STABLE int32_t U_EXPORT2
609 ucol_countAvailable(void);
610
611 #if !UCONFIG_NO_SERVICE
612 /**
613 * Create a string enumerator of all locales for which a valid
614 * collator may be opened.
615 * @param status input-output error code
616 * @return a string enumeration over locale strings. The caller is
617 * responsible for closing the result.
618 * @stable ICU 3.0
619 */
620 U_STABLE UEnumeration* U_EXPORT2
621 ucol_openAvailableLocales(UErrorCode *status);
622 #endif
623
624 /**
625 * Create a string enumerator of all possible keywords that are relevant to
626 * collation. At this point, the only recognized keyword for this
627 * service is "collation".
628 * @param status input-output error code
629 * @return a string enumeration over locale strings. The caller is
630 * responsible for closing the result.
631 * @stable ICU 3.0
632 */
633 U_STABLE UEnumeration* U_EXPORT2
634 ucol_getKeywords(UErrorCode *status);
635
636 /**
637 * Given a keyword, create a string enumeration of all values
638 * for that keyword that are currently in use.
639 * @param keyword a particular keyword as enumerated by
640 * ucol_getKeywords. If any other keyword is passed in, *status is set
641 * to U_ILLEGAL_ARGUMENT_ERROR.
642 * @param status input-output error code
643 * @return a string enumeration over collation keyword values, or NULL
644 * upon error. The caller is responsible for closing the result.
645 * @stable ICU 3.0
646 */
647 U_STABLE UEnumeration* U_EXPORT2
648 ucol_getKeywordValues(const char *keyword, UErrorCode *status);
649
650 /**
651 * Given a key and a locale, returns an array of string values in a preferred
652 * order that would make a difference. These are all and only those values where
653 * the open (creation) of the service with the locale formed from the input loca le
654 * plus input keyword and that value has different behavior than creation with t he
655 * input locale alone.
656 * @param key one of the keys supported by this service. For now, onl y
657 * "collation" is supported.
658 * @param locale the locale
659 * @param commonlyUsed if set to true it will return only commonly used values
660 * with the given locale in preferred order. Otherwise,
661 * it will return all the available values for the locale.
662 * @param status error status
663 * @return a string enumeration over keyword values for the given key and the lo cale.
664 * @stable ICU 4.2
665 */
666 U_STABLE UEnumeration* U_EXPORT2
667 ucol_getKeywordValuesForLocale(const char* key,
668 const char* locale,
669 UBool commonlyUsed,
670 UErrorCode* status);
671
672 /**
673 * Return the functionally equivalent locale for the given
674 * requested locale, with respect to given keyword, for the
675 * collation service. If two locales return the same result, then
676 * collators instantiated for these locales will behave
677 * equivalently. The converse is not always true; two collators
678 * may in fact be equivalent, but return different results, due to
679 * internal details. The return result has no other meaning than
680 * that stated above, and implies nothing as to the relationship
681 * between the two locales. This is intended for use by
682 * applications who wish to cache collators, or otherwise reuse
683 * collators when possible. The functional equivalent may change
684 * over time. For more information, please see the <a
685 * href="http://icu-project.org/userguide/locale.html#services">
686 * Locales and Services</a> section of the ICU User Guide.
687 * @param result fillin for the functionally equivalent locale
688 * @param resultCapacity capacity of the fillin buffer
689 * @param keyword a particular keyword as enumerated by
690 * ucol_getKeywords.
691 * @param locale the requested locale
692 * @param isAvailable if non-NULL, pointer to a fillin parameter that
693 * indicates whether the requested locale was 'available' to the
694 * collation service. A locale is defined as 'available' if it
695 * physically exists within the collation locale data.
696 * @param status pointer to input-output error code
697 * @return the actual buffer size needed for the locale. If greater
698 * than resultCapacity, the returned full name will be truncated and
699 * an error code will be returned.
700 * @stable ICU 3.0
701 */
702 U_STABLE int32_t U_EXPORT2
703 ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity,
704 const char* keyword, const char* locale,
705 UBool* isAvailable, UErrorCode* status);
706
707 /**
708 * Get the collation rules from a UCollator.
709 * The rules will follow the rule syntax.
710 * @param coll The UCollator to query.
711 * @param length
712 * @return The collation rules.
713 * @stable ICU 2.0
714 */
715 U_STABLE const UChar* U_EXPORT2
716 ucol_getRules( const UCollator *coll,
717 int32_t *length);
718
719 /** Get the short definition string for a collator. This API harvests the collat or's
720 * locale and the attribute set and produces a string that can be used for open ing
721 * a collator with the same properties using the ucol_openFromShortString API.
722 * This string will be normalized.
723 * The structure and the syntax of the string is defined in the "Naming collato rs"
724 * section of the users guide:
725 * http://icu-project.org/userguide/Collate_Concepts.html#Naming_Collators
726 * This API supports preflighting.
727 * @param coll a collator
728 * @param locale a locale that will appear as a collators locale in the resulti ng
729 * short string definition. If NULL, the locale will be harvested
730 * from the collator.
731 * @param buffer space to hold the resulting string
732 * @param capacity capacity of the buffer
733 * @param status for returning errors. All the preflighting errors are featured
734 * @return length of the resulting string
735 * @see ucol_openFromShortString
736 * @see ucol_normalizeShortDefinitionString
737 * @stable ICU 3.0
738 */
739 U_STABLE int32_t U_EXPORT2
740 ucol_getShortDefinitionString(const UCollator *coll,
741 const char *locale,
742 char *buffer,
743 int32_t capacity,
744 UErrorCode *status);
745
746 /** Verifies and normalizes short definition string.
747 * Normalized short definition string has all the option sorted by the argument name,
748 * so that equivalent definition strings are the same.
749 * This API supports preflighting.
750 * @param source definition string
751 * @param destination space to hold the resulting string
752 * @param capacity capacity of the buffer
753 * @param parseError if not NULL, structure that will get filled with error's p re
754 * and post context in case of error.
755 * @param status Error code. This API will return an error if an invalid at tribute
756 * or attribute/value combination is specified. All the prefl ighting
757 * errors are also featured
758 * @return length of the resulting normalized string.
759 *
760 * @see ucol_openFromShortString
761 * @see ucol_getShortDefinitionString
762 *
763 * @stable ICU 3.0
764 */
765
766 U_STABLE int32_t U_EXPORT2
767 ucol_normalizeShortDefinitionString(const char *source,
768 char *destination,
769 int32_t capacity,
770 UParseError *parseError,
771 UErrorCode *status);
772
773
774 /**
775 * Get a sort key for a string from a UCollator.
776 * Sort keys may be compared using <TT>strcmp</TT>.
777 *
778 * Like ICU functions that write to an output buffer, the buffer contents
779 * is undefined if the buffer capacity (resultLength parameter) is too small.
780 * Unlike ICU functions that write a string to an output buffer,
781 * the terminating zero byte is counted in the sort key length.
782 * @param coll The UCollator containing the collation rules.
783 * @param source The string to transform.
784 * @param sourceLength The length of source, or -1 if null-terminated.
785 * @param result A pointer to a buffer to receive the attribute.
786 * @param resultLength The maximum size of result.
787 * @return The size needed to fully store the sort key.
788 * If there was an internal error generating the sort key,
789 * a zero value is returned.
790 * @see ucol_keyHashCode
791 * @stable ICU 2.0
792 */
793 U_STABLE int32_t U_EXPORT2
794 ucol_getSortKey(const UCollator *coll,
795 const UChar *source,
796 int32_t sourceLength,
797 uint8_t *result,
798 int32_t resultLength);
799
800
801 /** Gets the next count bytes of a sort key. Caller needs
802 * to preserve state array between calls and to provide
803 * the same type of UCharIterator set with the same string.
804 * The destination buffer provided must be big enough to store
805 * the number of requested bytes. Generated sortkey is not
806 * compatible with sortkeys generated using ucol_getSortKey
807 * API, since we don't do any compression. If uncompressed
808 * sortkeys are required, this API can be used.
809 * @param coll The UCollator containing the collation rules.
810 * @param iter UCharIterator containing the string we need
811 * the sort key to be calculated for.
812 * @param state Opaque state of sortkey iteration.
813 * @param dest Buffer to hold the resulting sortkey part
814 * @param count number of sort key bytes required.
815 * @param status error code indicator.
816 * @return the actual number of bytes of a sortkey. It can be
817 * smaller than count if we have reached the end of
818 * the sort key.
819 * @stable ICU 2.6
820 */
821 U_STABLE int32_t U_EXPORT2
822 ucol_nextSortKeyPart(const UCollator *coll,
823 UCharIterator *iter,
824 uint32_t state[2],
825 uint8_t *dest, int32_t count,
826 UErrorCode *status);
827
828 /** enum that is taken by ucol_getBound API
829 * See below for explanation
830 * do not change the values assigned to the
831 * members of this enum. Underlying code
832 * depends on them having these numbers
833 * @stable ICU 2.0
834 */
835 typedef enum {
836 /** lower bound */
837 UCOL_BOUND_LOWER = 0,
838 /** upper bound that will match strings of exact size */
839 UCOL_BOUND_UPPER = 1,
840 /** upper bound that will match all the strings that have the same initial sub string as the given string */
841 UCOL_BOUND_UPPER_LONG = 2,
842 UCOL_BOUND_VALUE_COUNT
843 } UColBoundMode;
844
845 /**
846 * Produce a bound for a given sortkey and a number of levels.
847 * Return value is always the number of bytes needed, regardless of
848 * whether the result buffer was big enough or even valid.<br>
849 * Resulting bounds can be used to produce a range of strings that are
850 * between upper and lower bounds. For example, if bounds are produced
851 * for a sortkey of string "smith", strings between upper and lower
852 * bounds with one level would include "Smith", "SMITH", "sMiTh".<br>
853 * There are two upper bounds that can be produced. If UCOL_BOUND_UPPER
854 * is produced, strings matched would be as above. However, if bound
855 * produced using UCOL_BOUND_UPPER_LONG is used, the above example will
856 * also match "Smithsonian" and similar.<br>
857 * For more on usage, see example in cintltst/capitst.c in procedure
858 * TestBounds.
859 * Sort keys may be compared using <TT>strcmp</TT>.
860 * @param source The source sortkey.
861 * @param sourceLength The length of source, or -1 if null-terminated.
862 * (If an unmodified sortkey is passed, it is always null
863 * terminated).
864 * @param boundType Type of bound required. It can be UCOL_BOUND_LOWER, which
865 * produces a lower inclusive bound, UCOL_BOUND_UPPER, that
866 * produces upper bound that matches strings of the same length
867 * or UCOL_BOUND_UPPER_LONG that matches strings that have the
868 * same starting substring as the source string.
869 * @param noOfLevels Number of levels required in the resulting bound (for most
870 * uses, the recommended value is 1). See users guide for
871 * explanation on number of levels a sortkey can have.
872 * @param result A pointer to a buffer to receive the resulting sortkey.
873 * @param resultLength The maximum size of result.
874 * @param status Used for returning error code if something went wrong. If the
875 * number of levels requested is higher than the number of levels
876 * in the source key, a warning (U_SORT_KEY_TOO_SHORT_WARNING) is
877 * issued.
878 * @return The size needed to fully store the bound.
879 * @see ucol_keyHashCode
880 * @stable ICU 2.1
881 */
882 U_STABLE int32_t U_EXPORT2
883 ucol_getBound(const uint8_t *source,
884 int32_t sourceLength,
885 UColBoundMode boundType,
886 uint32_t noOfLevels,
887 uint8_t *result,
888 int32_t resultLength,
889 UErrorCode *status);
890
891 /**
892 * Gets the version information for a Collator. Version is currently
893 * an opaque 32-bit number which depends, among other things, on major
894 * versions of the collator tailoring and UCA.
895 * @param coll The UCollator to query.
896 * @param info the version # information, the result will be filled in
897 * @stable ICU 2.0
898 */
899 U_STABLE void U_EXPORT2
900 ucol_getVersion(const UCollator* coll, UVersionInfo info);
901
902 /**
903 * Gets the UCA version information for a Collator. Version is the
904 * UCA version number (3.1.1, 4.0).
905 * @param coll The UCollator to query.
906 * @param info the version # information, the result will be filled in
907 * @stable ICU 2.8
908 */
909 U_STABLE void U_EXPORT2
910 ucol_getUCAVersion(const UCollator* coll, UVersionInfo info);
911
912 /**
913 * Merge two sort keys. The levels are merged with their corresponding counterpa rts
914 * (primaries with primaries, secondaries with secondaries etc.). Between the va lues
915 * from the same level a separator is inserted.
916 * example (uncompressed):
917 * 191B1D 01 050505 01 910505 00 and 1F2123 01 050505 01 910505 00
918 * will be merged as
919 * 191B1D 02 1F212301 050505 02 050505 01 910505 02 910505 00
920 * This allows for concatenating of first and last names for sorting, among othe r things.
921 * If the destination buffer is not big enough, the results are undefined.
922 * If any of source lengths are zero or any of source pointers are NULL/undefine d,
923 * result is of size zero.
924 * @param src1 pointer to the first sortkey
925 * @param src1Length length of the first sortkey
926 * @param src2 pointer to the second sortkey
927 * @param src2Length length of the second sortkey
928 * @param dest buffer to hold the result
929 * @param destCapacity size of the buffer for the result
930 * @return size of the result. If the buffer is big enough size is always
931 * src1Length+src2Length-1
932 * @stable ICU 2.0
933 */
934 U_STABLE int32_t U_EXPORT2
935 ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,
936 const uint8_t *src2, int32_t src2Length,
937 uint8_t *dest, int32_t destCapacity);
938
939 /**
940 * Universal attribute setter
941 * @param coll collator which attributes are to be changed
942 * @param attr attribute type
943 * @param value attribute value
944 * @param status to indicate whether the operation went on smoothly or there wer e errors
945 * @see UColAttribute
946 * @see UColAttributeValue
947 * @see ucol_getAttribute
948 * @stable ICU 2.0
949 */
950 U_STABLE void U_EXPORT2
951 ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status);
952
953 /**
954 * Universal attribute getter
955 * @param coll collator which attributes are to be changed
956 * @param attr attribute type
957 * @return attribute value
958 * @param status to indicate whether the operation went on smoothly or there wer e errors
959 * @see UColAttribute
960 * @see UColAttributeValue
961 * @see ucol_setAttribute
962 * @stable ICU 2.0
963 */
964 U_STABLE UColAttributeValue U_EXPORT2
965 ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status) ;
966
967 /** Variable top
968 * is a two byte primary value which causes all the codepoints with primary valu es that
969 * are less or equal than the variable top to be shifted when alternate handling is set
970 * to UCOL_SHIFTED.
971 * Sets the variable top to a collation element value of a string supplied.
972 * @param coll collator which variable top needs to be changed
973 * @param varTop one or more (if contraction) UChars to which the variable top s hould be set
974 * @param len length of variable top string. If -1 it is considered to be zero t erminated.
975 * @param status error code. If error code is set, the return value is undefined .
976 * Errors set by this function are: <br>
977 * U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such
978 * a contraction<br>
979 * U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes
980 * @return a 32 bit value containing the value of the variable top in upper 16 b its.
981 * Lower 16 bits are undefined
982 * @see ucol_getVariableTop
983 * @see ucol_restoreVariableTop
984 * @stable ICU 2.0
985 */
986 U_STABLE uint32_t U_EXPORT2
987 ucol_setVariableTop(UCollator *coll,
988 const UChar *varTop, int32_t len,
989 UErrorCode *status);
990
991 /**
992 * Gets the variable top value of a Collator.
993 * Lower 16 bits are undefined and should be ignored.
994 * @param coll collator which variable top needs to be retrieved
995 * @param status error code (not changed by function). If error code is set,
996 * the return value is undefined.
997 * @return the variable top value of a Collator.
998 * @see ucol_setVariableTop
999 * @see ucol_restoreVariableTop
1000 * @stable ICU 2.0
1001 */
1002 U_STABLE uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCod e *status);
1003
1004 /**
1005 * Sets the variable top to a collation element value supplied. Variable top is
1006 * set to the upper 16 bits.
1007 * Lower 16 bits are ignored.
1008 * @param coll collator which variable top needs to be changed
1009 * @param varTop CE value, as returned by ucol_setVariableTop or ucol)getVariabl eTop
1010 * @param status error code (not changed by function)
1011 * @see ucol_getVariableTop
1012 * @see ucol_setVariableTop
1013 * @stable ICU 2.0
1014 */
1015 U_STABLE void U_EXPORT2
1016 ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *stat us);
1017
1018 /**
1019 * Thread safe cloning operation. The result is a clone of a given collator.
1020 * @param coll collator to be cloned
1021 * @param stackBuffer user allocated space for the new clone.
1022 * If NULL new memory will be allocated.
1023 * If buffer is not large enough, new memory will be allocated.
1024 * Clients can use the U_COL_SAFECLONE_BUFFERSIZE.
1025 * This will probably be enough to avoid memory allocations.
1026 * @param pBufferSize pointer to size of allocated space.
1027 * If *pBufferSize == 0, a sufficient size for use in cloning will
1028 * be returned ('pre-flighting')
1029 * If *pBufferSize is not enough for a stack-based safe clone,
1030 * new memory will be allocated.
1031 * @param status to indicate whether the operation went on smoothly or there wer e errors
1032 * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any
1033 * allocations were necessary.
1034 * @return pointer to the new clone
1035 * @see ucol_open
1036 * @see ucol_openRules
1037 * @see ucol_close
1038 * @stable ICU 2.0
1039 */
1040 U_STABLE UCollator* U_EXPORT2
1041 ucol_safeClone(const UCollator *coll,
1042 void *stackBuffer,
1043 int32_t *pBufferSize,
1044 UErrorCode *status);
1045
1046 /** default memory size for the new clone. It needs to be this large for os/400 large pointers
1047 * @stable ICU 2.0
1048 */
1049 #define U_COL_SAFECLONE_BUFFERSIZE 512
1050
1051 /**
1052 * Returns current rules. Delta defines whether full rules are returned or just the tailoring.
1053 * Returns number of UChars needed to store rules. If buffer is NULL or bufferLe n is not enough
1054 * to store rules, will store up to available space.
1055 * @param coll collator to get the rules from
1056 * @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES.
1057 * @param buffer buffer to store the result in. If NULL, you'll get no rules.
1058 * @param bufferLen lenght of buffer to store rules in. If less then needed you' ll get only the part that fits in.
1059 * @return current rules
1060 * @stable ICU 2.0
1061 */
1062 U_STABLE int32_t U_EXPORT2
1063 ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int3 2_t bufferLen);
1064
1065 /**
1066 * gets the locale name of the collator. If the collator
1067 * is instantiated from the rules, then this function returns
1068 * NULL.
1069 * @param coll The UCollator for which the locale is needed
1070 * @param type You can choose between requested, valid and actual
1071 * locale. For description see the definition of
1072 * ULocDataLocaleType in uloc.h
1073 * @param status error code of the operation
1074 * @return real locale name from which the collation data comes.
1075 * If the collator was instantiated from rules, returns
1076 * NULL.
1077 * @deprecated ICU 2.8 Use ucol_getLocaleByType instead
1078 */
1079 U_DEPRECATED const char * U_EXPORT2
1080 ucol_getLocale(const UCollator *coll, ULocDataLocaleType type, UErrorCode *statu s);
1081
1082
1083 /**
1084 * gets the locale name of the collator. If the collator
1085 * is instantiated from the rules, then this function returns
1086 * NULL.
1087 * @param coll The UCollator for which the locale is needed
1088 * @param type You can choose between requested, valid and actual
1089 * locale. For description see the definition of
1090 * ULocDataLocaleType in uloc.h
1091 * @param status error code of the operation
1092 * @return real locale name from which the collation data comes.
1093 * If the collator was instantiated from rules, returns
1094 * NULL.
1095 * @stable ICU 2.8
1096 */
1097 U_STABLE const char * U_EXPORT2
1098 ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status);
1099
1100 /**
1101 * Get an Unicode set that contains all the characters and sequences tailored in
1102 * this collator. The result must be disposed of by using uset_close.
1103 * @param coll The UCollator for which we want to get tailored chars
1104 * @param status error code of the operation
1105 * @return a pointer to newly created USet. Must be be disposed by using uset_cl ose
1106 * @see ucol_openRules
1107 * @see uset_close
1108 * @stable ICU 2.4
1109 */
1110 U_STABLE USet * U_EXPORT2
1111 ucol_getTailoredSet(const UCollator *coll, UErrorCode *status);
1112
1113 /**
1114 * Universal attribute getter that returns UCOL_DEFAULT if the value is default
1115 * @param coll collator which attributes are to be changed
1116 * @param attr attribute type
1117 * @return attribute value or UCOL_DEFAULT if the value is default
1118 * @param status to indicate whether the operation went on smoothly or there wer e errors
1119 * @see UColAttribute
1120 * @see UColAttributeValue
1121 * @see ucol_setAttribute
1122 * @internal ICU 3.0
1123 */
1124 U_INTERNAL UColAttributeValue U_EXPORT2
1125 ucol_getAttributeOrDefault(const UCollator *coll, UColAttribute attr, UErrorCode *status);
1126
1127 /** Check whether two collators are equal. Collators are considered equal if the y
1128 * will sort strings the same. This means that both the current attributes and the
1129 * rules must be equivalent. Currently used for RuleBasedCollator::operator==.
1130 * @param source first collator
1131 * @param target second collator
1132 * @return TRUE or FALSE
1133 * @internal ICU 3.0
1134 */
1135 U_INTERNAL UBool U_EXPORT2
1136 ucol_equals(const UCollator *source, const UCollator *target);
1137
1138 /** Calculates the set of unsafe code points, given a collator.
1139 * A character is unsafe if you could append any character and cause the order ing to alter significantly.
1140 * Collation sorts in normalized order, so anything that rearranges in normali zation can cause this.
1141 * Thus if you have a character like a_umlaut, and you add a lower_dot to it,
1142 * then it normalizes to a_lower_dot + umlaut, and sorts differently.
1143 * @param coll Collator
1144 * @param unsafe a fill-in set to receive the unsafe points
1145 * @param status for catching errors
1146 * @return number of elements in the set
1147 * @internal ICU 3.0
1148 */
1149 U_INTERNAL int32_t U_EXPORT2
1150 ucol_getUnsafeSet( const UCollator *coll,
1151 USet *unsafe,
1152 UErrorCode *status);
1153
1154 /** Reset UCA's static pointers. You don't want to use this, unless your static memory can go away.
1155 * @internal ICU 3.2.1
1156 */
1157 U_INTERNAL void U_EXPORT2
1158 ucol_forgetUCA(void);
1159
1160 /** Touches all resources needed for instantiating a collator from a short strin g definition,
1161 * thus filling up the cache.
1162 * @param definition A short string containing a locale and a set of attributes.
1163 * Attributes not explicitly mentioned are left at the default
1164 * state for a locale.
1165 * @param parseError if not NULL, structure that will get filled with error's pr e
1166 * and post context in case of error.
1167 * @param forceDefaults if FALSE, the settings that are the same as the collator
1168 * default settings will not be applied (for example, setting
1169 * French secondary on a French collator would not be executed ).
1170 * If TRUE, all the settings will be applied regardless of the
1171 * collator default value. If the definition
1172 * strings are to be cached, should be set to FALSE.
1173 * @param status Error code. Apart from regular error conditions connected t o
1174 * instantiating collators (like out of memory or similar), th is
1175 * API will return an error if an invalid attribute or attribu te/value
1176 * combination is specified.
1177 * @see ucol_openFromShortString
1178 * @internal ICU 3.2.1
1179 */
1180 U_INTERNAL void U_EXPORT2
1181 ucol_prepareShortStringOpen( const char *definition,
1182 UBool forceDefaults,
1183 UParseError *parseError,
1184 UErrorCode *status);
1185
1186 /** Creates a binary image of a collator. This binary image can be stored and
1187 * later used to instantiate a collator using ucol_openBinary.
1188 * This API supports preflighting.
1189 * @param coll Collator
1190 * @param buffer a fill-in buffer to receive the binary image
1191 * @param capacity capacity of the destination buffer
1192 * @param status for catching errors
1193 * @return size of the image
1194 * @see ucol_openBinary
1195 * @stable ICU 3.2
1196 */
1197 U_STABLE int32_t U_EXPORT2
1198 ucol_cloneBinary(const UCollator *coll,
1199 uint8_t *buffer, int32_t capacity,
1200 UErrorCode *status);
1201
1202 /** Opens a collator from a collator binary image created using
1203 * ucol_cloneBinary. Binary image used in instantiation of the
1204 * collator remains owned by the user and should stay around for
1205 * the lifetime of the collator. The API also takes a base collator
1206 * which usualy should be UCA.
1207 * @param bin binary image owned by the user and required through the
1208 * lifetime of the collator
1209 * @param length size of the image. If negative, the API will try to
1210 * figure out the length of the image
1211 * @param base fallback collator, usually UCA. Base is required to be
1212 * present through the lifetime of the collator. Currently
1213 * it cannot be NULL.
1214 * @param status for catching errors
1215 * @return newly created collator
1216 * @see ucol_cloneBinary
1217 * @stable ICU 3.2
1218 */
1219 U_STABLE UCollator* U_EXPORT2
1220 ucol_openBinary(const uint8_t *bin, int32_t length,
1221 const UCollator *base,
1222 UErrorCode *status);
1223
1224
1225 #endif /* #if !UCONFIG_NO_COLLATION */
1226
1227 #endif
OLDNEW
« no previous file with comments | « public/i18n/unicode/ucal.h ('k') | public/i18n/unicode/ucoleitr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698