Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * Copyright (C) 1997-2011, International Business Machines |
michael@0 | 4 | * Corporation and others. All Rights Reserved. |
michael@0 | 5 | ******************************************************************************* |
michael@0 | 6 | * Date Name Description |
michael@0 | 7 | * 06/21/00 aliu Creation. |
michael@0 | 8 | ******************************************************************************* |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | #ifndef UTRANS_H |
michael@0 | 12 | #define UTRANS_H |
michael@0 | 13 | |
michael@0 | 14 | #include "unicode/utypes.h" |
michael@0 | 15 | |
michael@0 | 16 | #if !UCONFIG_NO_TRANSLITERATION |
michael@0 | 17 | |
michael@0 | 18 | #include "unicode/localpointer.h" |
michael@0 | 19 | #include "unicode/urep.h" |
michael@0 | 20 | #include "unicode/parseerr.h" |
michael@0 | 21 | #include "unicode/uenum.h" |
michael@0 | 22 | |
michael@0 | 23 | /******************************************************************** |
michael@0 | 24 | * General Notes |
michael@0 | 25 | ******************************************************************** |
michael@0 | 26 | */ |
michael@0 | 27 | /** |
michael@0 | 28 | * \file |
michael@0 | 29 | * \brief C API: Transliterator |
michael@0 | 30 | * |
michael@0 | 31 | * <h2> Transliteration </h2> |
michael@0 | 32 | * The data structures and functions described in this header provide |
michael@0 | 33 | * transliteration services. Transliteration services are implemented |
michael@0 | 34 | * as C++ classes. The comments and documentation in this header |
michael@0 | 35 | * assume the reader is familiar with the C++ headers translit.h and |
michael@0 | 36 | * associated documentation. |
michael@0 | 37 | * |
michael@0 | 38 | * A significant but incomplete subset of the C++ transliteration |
michael@0 | 39 | * services are available to C code through this header. In order to |
michael@0 | 40 | * access more complex transliteration services, refer to the C++ |
michael@0 | 41 | * headers and documentation. |
michael@0 | 42 | * |
michael@0 | 43 | * There are two sets of functions for working with transliterator IDs: |
michael@0 | 44 | * |
michael@0 | 45 | * An old, deprecated set uses char * IDs, which works for true and pure |
michael@0 | 46 | * identifiers that these APIs were designed for, |
michael@0 | 47 | * for example "Cyrillic-Latin". |
michael@0 | 48 | * It does not work when the ID contains filters ("[:Script=Cyrl:]") |
michael@0 | 49 | * or even a complete set of rules because then the ID string contains more |
michael@0 | 50 | * than just "invariant" characters (see utypes.h). |
michael@0 | 51 | * |
michael@0 | 52 | * A new set of functions replaces the old ones and uses UChar * IDs, |
michael@0 | 53 | * paralleling the UnicodeString IDs in the C++ API. (New in ICU 2.8.) |
michael@0 | 54 | */ |
michael@0 | 55 | |
michael@0 | 56 | /******************************************************************** |
michael@0 | 57 | * Data Structures |
michael@0 | 58 | ********************************************************************/ |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * An opaque transliterator for use in C. Open with utrans_openxxx() |
michael@0 | 62 | * and close with utrans_close() when done. Equivalent to the C++ class |
michael@0 | 63 | * Transliterator and its subclasses. |
michael@0 | 64 | * @see Transliterator |
michael@0 | 65 | * @stable ICU 2.0 |
michael@0 | 66 | */ |
michael@0 | 67 | typedef void* UTransliterator; |
michael@0 | 68 | |
michael@0 | 69 | /** |
michael@0 | 70 | * Direction constant indicating the direction in a transliterator, |
michael@0 | 71 | * e.g., the forward or reverse rules of a RuleBasedTransliterator. |
michael@0 | 72 | * Specified when a transliterator is opened. An "A-B" transliterator |
michael@0 | 73 | * transliterates A to B when operating in the forward direction, and |
michael@0 | 74 | * B to A when operating in the reverse direction. |
michael@0 | 75 | * @stable ICU 2.0 |
michael@0 | 76 | */ |
michael@0 | 77 | typedef enum UTransDirection { |
michael@0 | 78 | |
michael@0 | 79 | /** |
michael@0 | 80 | * UTRANS_FORWARD means from <source> to <target> for a |
michael@0 | 81 | * transliterator with ID <source>-<target>. For a transliterator |
michael@0 | 82 | * opened using a rule, it means forward direction rules, e.g., |
michael@0 | 83 | * "A > B". |
michael@0 | 84 | */ |
michael@0 | 85 | UTRANS_FORWARD, |
michael@0 | 86 | |
michael@0 | 87 | /** |
michael@0 | 88 | * UTRANS_REVERSE means from <target> to <source> for a |
michael@0 | 89 | * transliterator with ID <source>-<target>. For a transliterator |
michael@0 | 90 | * opened using a rule, it means reverse direction rules, e.g., |
michael@0 | 91 | * "A < B". |
michael@0 | 92 | */ |
michael@0 | 93 | UTRANS_REVERSE |
michael@0 | 94 | |
michael@0 | 95 | } UTransDirection; |
michael@0 | 96 | |
michael@0 | 97 | /** |
michael@0 | 98 | * Position structure for utrans_transIncremental() incremental |
michael@0 | 99 | * transliteration. This structure defines two substrings of the text |
michael@0 | 100 | * being transliterated. The first region, [contextStart, |
michael@0 | 101 | * contextLimit), defines what characters the transliterator will read |
michael@0 | 102 | * as context. The second region, [start, limit), defines what |
michael@0 | 103 | * characters will actually be transliterated. The second region |
michael@0 | 104 | * should be a subset of the first. |
michael@0 | 105 | * |
michael@0 | 106 | * <p>After a transliteration operation, some of the indices in this |
michael@0 | 107 | * structure will be modified. See the field descriptions for |
michael@0 | 108 | * details. |
michael@0 | 109 | * |
michael@0 | 110 | * <p>contextStart <= start <= limit <= contextLimit |
michael@0 | 111 | * |
michael@0 | 112 | * <p>Note: All index values in this structure must be at code point |
michael@0 | 113 | * boundaries. That is, none of them may occur between two code units |
michael@0 | 114 | * of a surrogate pair. If any index does split a surrogate pair, |
michael@0 | 115 | * results are unspecified. |
michael@0 | 116 | * |
michael@0 | 117 | * @stable ICU 2.0 |
michael@0 | 118 | */ |
michael@0 | 119 | typedef struct UTransPosition { |
michael@0 | 120 | |
michael@0 | 121 | /** |
michael@0 | 122 | * Beginning index, inclusive, of the context to be considered for |
michael@0 | 123 | * a transliteration operation. The transliterator will ignore |
michael@0 | 124 | * anything before this index. INPUT/OUTPUT parameter: This parameter |
michael@0 | 125 | * is updated by a transliteration operation to reflect the maximum |
michael@0 | 126 | * amount of antecontext needed by a transliterator. |
michael@0 | 127 | * @stable ICU 2.4 |
michael@0 | 128 | */ |
michael@0 | 129 | int32_t contextStart; |
michael@0 | 130 | |
michael@0 | 131 | /** |
michael@0 | 132 | * Ending index, exclusive, of the context to be considered for a |
michael@0 | 133 | * transliteration operation. The transliterator will ignore |
michael@0 | 134 | * anything at or after this index. INPUT/OUTPUT parameter: This |
michael@0 | 135 | * parameter is updated to reflect changes in the length of the |
michael@0 | 136 | * text, but points to the same logical position in the text. |
michael@0 | 137 | * @stable ICU 2.4 |
michael@0 | 138 | */ |
michael@0 | 139 | int32_t contextLimit; |
michael@0 | 140 | |
michael@0 | 141 | /** |
michael@0 | 142 | * Beginning index, inclusive, of the text to be transliteratd. |
michael@0 | 143 | * INPUT/OUTPUT parameter: This parameter is advanced past |
michael@0 | 144 | * characters that have already been transliterated by a |
michael@0 | 145 | * transliteration operation. |
michael@0 | 146 | * @stable ICU 2.4 |
michael@0 | 147 | */ |
michael@0 | 148 | int32_t start; |
michael@0 | 149 | |
michael@0 | 150 | /** |
michael@0 | 151 | * Ending index, exclusive, of the text to be transliteratd. |
michael@0 | 152 | * INPUT/OUTPUT parameter: This parameter is updated to reflect |
michael@0 | 153 | * changes in the length of the text, but points to the same |
michael@0 | 154 | * logical position in the text. |
michael@0 | 155 | * @stable ICU 2.4 |
michael@0 | 156 | */ |
michael@0 | 157 | int32_t limit; |
michael@0 | 158 | |
michael@0 | 159 | } UTransPosition; |
michael@0 | 160 | |
michael@0 | 161 | /******************************************************************** |
michael@0 | 162 | * General API |
michael@0 | 163 | ********************************************************************/ |
michael@0 | 164 | |
michael@0 | 165 | /** |
michael@0 | 166 | * Open a custom transliterator, given a custom rules string |
michael@0 | 167 | * OR |
michael@0 | 168 | * a system transliterator, given its ID. |
michael@0 | 169 | * Any non-NULL result from this function should later be closed with |
michael@0 | 170 | * utrans_close(). |
michael@0 | 171 | * |
michael@0 | 172 | * @param id a valid transliterator ID |
michael@0 | 173 | * @param idLength the length of the ID string, or -1 if NUL-terminated |
michael@0 | 174 | * @param dir the desired direction |
michael@0 | 175 | * @param rules the transliterator rules. See the C++ header rbt.h for |
michael@0 | 176 | * rules syntax. If NULL then a system transliterator matching |
michael@0 | 177 | * the ID is returned. |
michael@0 | 178 | * @param rulesLength the length of the rules, or -1 if the rules |
michael@0 | 179 | * are NUL-terminated. |
michael@0 | 180 | * @param parseError a pointer to a UParseError struct to receive the details |
michael@0 | 181 | * of any parsing errors. This parameter may be NULL if no |
michael@0 | 182 | * parsing error details are desired. |
michael@0 | 183 | * @param pErrorCode a pointer to the UErrorCode |
michael@0 | 184 | * @return a transliterator pointer that may be passed to other |
michael@0 | 185 | * utrans_xxx() functions, or NULL if the open call fails. |
michael@0 | 186 | * @stable ICU 2.8 |
michael@0 | 187 | */ |
michael@0 | 188 | U_STABLE UTransliterator* U_EXPORT2 |
michael@0 | 189 | utrans_openU(const UChar *id, |
michael@0 | 190 | int32_t idLength, |
michael@0 | 191 | UTransDirection dir, |
michael@0 | 192 | const UChar *rules, |
michael@0 | 193 | int32_t rulesLength, |
michael@0 | 194 | UParseError *parseError, |
michael@0 | 195 | UErrorCode *pErrorCode); |
michael@0 | 196 | |
michael@0 | 197 | /** |
michael@0 | 198 | * Open an inverse of an existing transliterator. For this to work, |
michael@0 | 199 | * the inverse must be registered with the system. For example, if |
michael@0 | 200 | * the Transliterator "A-B" is opened, and then its inverse is opened, |
michael@0 | 201 | * the result is the Transliterator "B-A", if such a transliterator is |
michael@0 | 202 | * registered with the system. Otherwise the result is NULL and a |
michael@0 | 203 | * failing UErrorCode is set. Any non-NULL result from this function |
michael@0 | 204 | * should later be closed with utrans_close(). |
michael@0 | 205 | * |
michael@0 | 206 | * @param trans the transliterator to open the inverse of. |
michael@0 | 207 | * @param status a pointer to the UErrorCode |
michael@0 | 208 | * @return a pointer to a newly-opened transliterator that is the |
michael@0 | 209 | * inverse of trans, or NULL if the open call fails. |
michael@0 | 210 | * @stable ICU 2.0 |
michael@0 | 211 | */ |
michael@0 | 212 | U_STABLE UTransliterator* U_EXPORT2 |
michael@0 | 213 | utrans_openInverse(const UTransliterator* trans, |
michael@0 | 214 | UErrorCode* status); |
michael@0 | 215 | |
michael@0 | 216 | /** |
michael@0 | 217 | * Create a copy of a transliterator. Any non-NULL result from this |
michael@0 | 218 | * function should later be closed with utrans_close(). |
michael@0 | 219 | * |
michael@0 | 220 | * @param trans the transliterator to be copied. |
michael@0 | 221 | * @param status a pointer to the UErrorCode |
michael@0 | 222 | * @return a transliterator pointer that may be passed to other |
michael@0 | 223 | * utrans_xxx() functions, or NULL if the clone call fails. |
michael@0 | 224 | * @stable ICU 2.0 |
michael@0 | 225 | */ |
michael@0 | 226 | U_STABLE UTransliterator* U_EXPORT2 |
michael@0 | 227 | utrans_clone(const UTransliterator* trans, |
michael@0 | 228 | UErrorCode* status); |
michael@0 | 229 | |
michael@0 | 230 | /** |
michael@0 | 231 | * Close a transliterator. Any non-NULL pointer returned by |
michael@0 | 232 | * utrans_openXxx() or utrans_clone() should eventually be closed. |
michael@0 | 233 | * @param trans the transliterator to be closed. |
michael@0 | 234 | * @stable ICU 2.0 |
michael@0 | 235 | */ |
michael@0 | 236 | U_STABLE void U_EXPORT2 |
michael@0 | 237 | utrans_close(UTransliterator* trans); |
michael@0 | 238 | |
michael@0 | 239 | #if U_SHOW_CPLUSPLUS_API |
michael@0 | 240 | |
michael@0 | 241 | U_NAMESPACE_BEGIN |
michael@0 | 242 | |
michael@0 | 243 | /** |
michael@0 | 244 | * \class LocalUTransliteratorPointer |
michael@0 | 245 | * "Smart pointer" class, closes a UTransliterator via utrans_close(). |
michael@0 | 246 | * For most methods see the LocalPointerBase base class. |
michael@0 | 247 | * |
michael@0 | 248 | * @see LocalPointerBase |
michael@0 | 249 | * @see LocalPointer |
michael@0 | 250 | * @stable ICU 4.4 |
michael@0 | 251 | */ |
michael@0 | 252 | U_DEFINE_LOCAL_OPEN_POINTER(LocalUTransliteratorPointer, UTransliterator, utrans_close); |
michael@0 | 253 | |
michael@0 | 254 | U_NAMESPACE_END |
michael@0 | 255 | |
michael@0 | 256 | #endif |
michael@0 | 257 | |
michael@0 | 258 | /** |
michael@0 | 259 | * Return the programmatic identifier for this transliterator. |
michael@0 | 260 | * If this identifier is passed to utrans_openU(), it will open |
michael@0 | 261 | * a transliterator equivalent to this one, if the ID has been |
michael@0 | 262 | * registered. |
michael@0 | 263 | * |
michael@0 | 264 | * @param trans the transliterator to return the ID of. |
michael@0 | 265 | * @param resultLength pointer to an output variable receiving the length |
michael@0 | 266 | * of the ID string; can be NULL |
michael@0 | 267 | * @return the NUL-terminated ID string. This pointer remains |
michael@0 | 268 | * valid until utrans_close() is called on this transliterator. |
michael@0 | 269 | * |
michael@0 | 270 | * @stable ICU 2.8 |
michael@0 | 271 | */ |
michael@0 | 272 | U_STABLE const UChar * U_EXPORT2 |
michael@0 | 273 | utrans_getUnicodeID(const UTransliterator *trans, |
michael@0 | 274 | int32_t *resultLength); |
michael@0 | 275 | |
michael@0 | 276 | /** |
michael@0 | 277 | * Register an open transliterator with the system. When |
michael@0 | 278 | * utrans_open() is called with an ID string that is equal to that |
michael@0 | 279 | * returned by utrans_getID(adoptedTrans,...), then |
michael@0 | 280 | * utrans_clone(adoptedTrans,...) is returned. |
michael@0 | 281 | * |
michael@0 | 282 | * <p>NOTE: After this call the system owns the adoptedTrans and will |
michael@0 | 283 | * close it. The user must not call utrans_close() on adoptedTrans. |
michael@0 | 284 | * |
michael@0 | 285 | * @param adoptedTrans a transliterator, typically the result of |
michael@0 | 286 | * utrans_openRules(), to be registered with the system. |
michael@0 | 287 | * @param status a pointer to the UErrorCode |
michael@0 | 288 | * @stable ICU 2.0 |
michael@0 | 289 | */ |
michael@0 | 290 | U_STABLE void U_EXPORT2 |
michael@0 | 291 | utrans_register(UTransliterator* adoptedTrans, |
michael@0 | 292 | UErrorCode* status); |
michael@0 | 293 | |
michael@0 | 294 | /** |
michael@0 | 295 | * Unregister a transliterator from the system. After this call the |
michael@0 | 296 | * system will no longer recognize the given ID when passed to |
michael@0 | 297 | * utrans_open(). If the ID is invalid then nothing is done. |
michael@0 | 298 | * |
michael@0 | 299 | * @param id an ID to unregister |
michael@0 | 300 | * @param idLength the length of id, or -1 if id is zero-terminated |
michael@0 | 301 | * @stable ICU 2.8 |
michael@0 | 302 | */ |
michael@0 | 303 | U_STABLE void U_EXPORT2 |
michael@0 | 304 | utrans_unregisterID(const UChar* id, int32_t idLength); |
michael@0 | 305 | |
michael@0 | 306 | /** |
michael@0 | 307 | * Set the filter used by a transliterator. A filter can be used to |
michael@0 | 308 | * make the transliterator pass certain characters through untouched. |
michael@0 | 309 | * The filter is expressed using a UnicodeSet pattern. If the |
michael@0 | 310 | * filterPattern is NULL or the empty string, then the transliterator |
michael@0 | 311 | * will be reset to use no filter. |
michael@0 | 312 | * |
michael@0 | 313 | * @param trans the transliterator |
michael@0 | 314 | * @param filterPattern a pattern string, in the form accepted by |
michael@0 | 315 | * UnicodeSet, specifying which characters to apply the |
michael@0 | 316 | * transliteration to. May be NULL or the empty string to indicate no |
michael@0 | 317 | * filter. |
michael@0 | 318 | * @param filterPatternLen the length of filterPattern, or -1 if |
michael@0 | 319 | * filterPattern is zero-terminated |
michael@0 | 320 | * @param status a pointer to the UErrorCode |
michael@0 | 321 | * @see UnicodeSet |
michael@0 | 322 | * @stable ICU 2.0 |
michael@0 | 323 | */ |
michael@0 | 324 | U_STABLE void U_EXPORT2 |
michael@0 | 325 | utrans_setFilter(UTransliterator* trans, |
michael@0 | 326 | const UChar* filterPattern, |
michael@0 | 327 | int32_t filterPatternLen, |
michael@0 | 328 | UErrorCode* status); |
michael@0 | 329 | |
michael@0 | 330 | /** |
michael@0 | 331 | * Return the number of system transliterators. |
michael@0 | 332 | * It is recommended to use utrans_openIDs() instead. |
michael@0 | 333 | * |
michael@0 | 334 | * @return the number of system transliterators. |
michael@0 | 335 | * @stable ICU 2.0 |
michael@0 | 336 | */ |
michael@0 | 337 | U_STABLE int32_t U_EXPORT2 |
michael@0 | 338 | utrans_countAvailableIDs(void); |
michael@0 | 339 | |
michael@0 | 340 | /** |
michael@0 | 341 | * Return a UEnumeration for the available transliterators. |
michael@0 | 342 | * |
michael@0 | 343 | * @param pErrorCode Pointer to the UErrorCode in/out parameter. |
michael@0 | 344 | * @return UEnumeration for the available transliterators. |
michael@0 | 345 | * Close with uenum_close(). |
michael@0 | 346 | * |
michael@0 | 347 | * @stable ICU 2.8 |
michael@0 | 348 | */ |
michael@0 | 349 | U_STABLE UEnumeration * U_EXPORT2 |
michael@0 | 350 | utrans_openIDs(UErrorCode *pErrorCode); |
michael@0 | 351 | |
michael@0 | 352 | /******************************************************************** |
michael@0 | 353 | * Transliteration API |
michael@0 | 354 | ********************************************************************/ |
michael@0 | 355 | |
michael@0 | 356 | /** |
michael@0 | 357 | * Transliterate a segment of a UReplaceable string. The string is |
michael@0 | 358 | * passed in as a UReplaceable pointer rep and a UReplaceableCallbacks |
michael@0 | 359 | * function pointer struct repFunc. Functions in the repFunc struct |
michael@0 | 360 | * will be called in order to modify the rep string. |
michael@0 | 361 | * |
michael@0 | 362 | * @param trans the transliterator |
michael@0 | 363 | * @param rep a pointer to the string. This will be passed to the |
michael@0 | 364 | * repFunc functions. |
michael@0 | 365 | * @param repFunc a set of function pointers that will be used to |
michael@0 | 366 | * modify the string pointed to by rep. |
michael@0 | 367 | * @param start the beginning index, inclusive; <code>0 <= start <= |
michael@0 | 368 | * limit</code>. |
michael@0 | 369 | * @param limit pointer to the ending index, exclusive; <code>start <= |
michael@0 | 370 | * limit <= repFunc->length(rep)</code>. Upon return, *limit will |
michael@0 | 371 | * contain the new limit index. The text previously occupying |
michael@0 | 372 | * <code>[start, limit)</code> has been transliterated, possibly to a |
michael@0 | 373 | * string of a different length, at <code>[start, |
michael@0 | 374 | * </code><em>new-limit</em><code>)</code>, where <em>new-limit</em> |
michael@0 | 375 | * is the return value. |
michael@0 | 376 | * @param status a pointer to the UErrorCode |
michael@0 | 377 | * @stable ICU 2.0 |
michael@0 | 378 | */ |
michael@0 | 379 | U_STABLE void U_EXPORT2 |
michael@0 | 380 | utrans_trans(const UTransliterator* trans, |
michael@0 | 381 | UReplaceable* rep, |
michael@0 | 382 | UReplaceableCallbacks* repFunc, |
michael@0 | 383 | int32_t start, |
michael@0 | 384 | int32_t* limit, |
michael@0 | 385 | UErrorCode* status); |
michael@0 | 386 | |
michael@0 | 387 | /** |
michael@0 | 388 | * Transliterate the portion of the UReplaceable text buffer that can |
michael@0 | 389 | * be transliterated unambiguosly. This method is typically called |
michael@0 | 390 | * after new text has been inserted, e.g. as a result of a keyboard |
michael@0 | 391 | * event. The transliterator will try to transliterate characters of |
michael@0 | 392 | * <code>rep</code> between <code>index.cursor</code> and |
michael@0 | 393 | * <code>index.limit</code>. Characters before |
michael@0 | 394 | * <code>index.cursor</code> will not be changed. |
michael@0 | 395 | * |
michael@0 | 396 | * <p>Upon return, values in <code>index</code> will be updated. |
michael@0 | 397 | * <code>index.start</code> will be advanced to the first |
michael@0 | 398 | * character that future calls to this method will read. |
michael@0 | 399 | * <code>index.cursor</code> and <code>index.limit</code> will |
michael@0 | 400 | * be adjusted to delimit the range of text that future calls to |
michael@0 | 401 | * this method may change. |
michael@0 | 402 | * |
michael@0 | 403 | * <p>Typical usage of this method begins with an initial call |
michael@0 | 404 | * with <code>index.start</code> and <code>index.limit</code> |
michael@0 | 405 | * set to indicate the portion of <code>text</code> to be |
michael@0 | 406 | * transliterated, and <code>index.cursor == index.start</code>. |
michael@0 | 407 | * Thereafter, <code>index</code> can be used without |
michael@0 | 408 | * modification in future calls, provided that all changes to |
michael@0 | 409 | * <code>text</code> are made via this method. |
michael@0 | 410 | * |
michael@0 | 411 | * <p>This method assumes that future calls may be made that will |
michael@0 | 412 | * insert new text into the buffer. As a result, it only performs |
michael@0 | 413 | * unambiguous transliterations. After the last call to this method, |
michael@0 | 414 | * there may be untransliterated text that is waiting for more input |
michael@0 | 415 | * to resolve an ambiguity. In order to perform these pending |
michael@0 | 416 | * transliterations, clients should call utrans_trans() with a start |
michael@0 | 417 | * of index.start and a limit of index.end after the last call to this |
michael@0 | 418 | * method has been made. |
michael@0 | 419 | * |
michael@0 | 420 | * @param trans the transliterator |
michael@0 | 421 | * @param rep a pointer to the string. This will be passed to the |
michael@0 | 422 | * repFunc functions. |
michael@0 | 423 | * @param repFunc a set of function pointers that will be used to |
michael@0 | 424 | * modify the string pointed to by rep. |
michael@0 | 425 | * @param pos a struct containing the start and limit indices of the |
michael@0 | 426 | * text to be read and the text to be transliterated |
michael@0 | 427 | * @param status a pointer to the UErrorCode |
michael@0 | 428 | * @stable ICU 2.0 |
michael@0 | 429 | */ |
michael@0 | 430 | U_STABLE void U_EXPORT2 |
michael@0 | 431 | utrans_transIncremental(const UTransliterator* trans, |
michael@0 | 432 | UReplaceable* rep, |
michael@0 | 433 | UReplaceableCallbacks* repFunc, |
michael@0 | 434 | UTransPosition* pos, |
michael@0 | 435 | UErrorCode* status); |
michael@0 | 436 | |
michael@0 | 437 | /** |
michael@0 | 438 | * Transliterate a segment of a UChar* string. The string is passed |
michael@0 | 439 | * in in a UChar* buffer. The string is modified in place. If the |
michael@0 | 440 | * result is longer than textCapacity, it is truncated. The actual |
michael@0 | 441 | * length of the result is returned in *textLength, if textLength is |
michael@0 | 442 | * non-NULL. *textLength may be greater than textCapacity, but only |
michael@0 | 443 | * textCapacity UChars will be written to *text, including the zero |
michael@0 | 444 | * terminator. |
michael@0 | 445 | * |
michael@0 | 446 | * @param trans the transliterator |
michael@0 | 447 | * @param text a pointer to a buffer containing the text to be |
michael@0 | 448 | * transliterated on input and the result text on output. |
michael@0 | 449 | * @param textLength a pointer to the length of the string in text. |
michael@0 | 450 | * If the length is -1 then the string is assumed to be |
michael@0 | 451 | * zero-terminated. Upon return, the new length is stored in |
michael@0 | 452 | * *textLength. If textLength is NULL then the string is assumed to |
michael@0 | 453 | * be zero-terminated. |
michael@0 | 454 | * @param textCapacity a pointer to the length of the text buffer. |
michael@0 | 455 | * Upon return, |
michael@0 | 456 | * @param start the beginning index, inclusive; <code>0 <= start <= |
michael@0 | 457 | * limit</code>. |
michael@0 | 458 | * @param limit pointer to the ending index, exclusive; <code>start <= |
michael@0 | 459 | * limit <= repFunc->length(rep)</code>. Upon return, *limit will |
michael@0 | 460 | * contain the new limit index. The text previously occupying |
michael@0 | 461 | * <code>[start, limit)</code> has been transliterated, possibly to a |
michael@0 | 462 | * string of a different length, at <code>[start, |
michael@0 | 463 | * </code><em>new-limit</em><code>)</code>, where <em>new-limit</em> |
michael@0 | 464 | * is the return value. |
michael@0 | 465 | * @param status a pointer to the UErrorCode |
michael@0 | 466 | * @stable ICU 2.0 |
michael@0 | 467 | */ |
michael@0 | 468 | U_STABLE void U_EXPORT2 |
michael@0 | 469 | utrans_transUChars(const UTransliterator* trans, |
michael@0 | 470 | UChar* text, |
michael@0 | 471 | int32_t* textLength, |
michael@0 | 472 | int32_t textCapacity, |
michael@0 | 473 | int32_t start, |
michael@0 | 474 | int32_t* limit, |
michael@0 | 475 | UErrorCode* status); |
michael@0 | 476 | |
michael@0 | 477 | /** |
michael@0 | 478 | * Transliterate the portion of the UChar* text buffer that can be |
michael@0 | 479 | * transliterated unambiguosly. See utrans_transIncremental(). The |
michael@0 | 480 | * string is passed in in a UChar* buffer. The string is modified in |
michael@0 | 481 | * place. If the result is longer than textCapacity, it is truncated. |
michael@0 | 482 | * The actual length of the result is returned in *textLength, if |
michael@0 | 483 | * textLength is non-NULL. *textLength may be greater than |
michael@0 | 484 | * textCapacity, but only textCapacity UChars will be written to |
michael@0 | 485 | * *text, including the zero terminator. See utrans_transIncremental() |
michael@0 | 486 | * for usage details. |
michael@0 | 487 | * |
michael@0 | 488 | * @param trans the transliterator |
michael@0 | 489 | * @param text a pointer to a buffer containing the text to be |
michael@0 | 490 | * transliterated on input and the result text on output. |
michael@0 | 491 | * @param textLength a pointer to the length of the string in text. |
michael@0 | 492 | * If the length is -1 then the string is assumed to be |
michael@0 | 493 | * zero-terminated. Upon return, the new length is stored in |
michael@0 | 494 | * *textLength. If textLength is NULL then the string is assumed to |
michael@0 | 495 | * be zero-terminated. |
michael@0 | 496 | * @param textCapacity the length of the text buffer |
michael@0 | 497 | * @param pos a struct containing the start and limit indices of the |
michael@0 | 498 | * text to be read and the text to be transliterated |
michael@0 | 499 | * @param status a pointer to the UErrorCode |
michael@0 | 500 | * @see utrans_transIncremental |
michael@0 | 501 | * @stable ICU 2.0 |
michael@0 | 502 | */ |
michael@0 | 503 | U_STABLE void U_EXPORT2 |
michael@0 | 504 | utrans_transIncrementalUChars(const UTransliterator* trans, |
michael@0 | 505 | UChar* text, |
michael@0 | 506 | int32_t* textLength, |
michael@0 | 507 | int32_t textCapacity, |
michael@0 | 508 | UTransPosition* pos, |
michael@0 | 509 | UErrorCode* status); |
michael@0 | 510 | |
michael@0 | 511 | /* deprecated API ----------------------------------------------------------- */ |
michael@0 | 512 | |
michael@0 | 513 | #ifndef U_HIDE_DEPRECATED_API |
michael@0 | 514 | |
michael@0 | 515 | /* see utrans.h documentation for why these functions are deprecated */ |
michael@0 | 516 | |
michael@0 | 517 | /** |
michael@0 | 518 | * Deprecated, use utrans_openU() instead. |
michael@0 | 519 | * Open a custom transliterator, given a custom rules string |
michael@0 | 520 | * OR |
michael@0 | 521 | * a system transliterator, given its ID. |
michael@0 | 522 | * Any non-NULL result from this function should later be closed with |
michael@0 | 523 | * utrans_close(). |
michael@0 | 524 | * |
michael@0 | 525 | * @param id a valid ID, as returned by utrans_getAvailableID() |
michael@0 | 526 | * @param dir the desired direction |
michael@0 | 527 | * @param rules the transliterator rules. See the C++ header rbt.h |
michael@0 | 528 | * for rules syntax. If NULL then a system transliterator matching |
michael@0 | 529 | * the ID is returned. |
michael@0 | 530 | * @param rulesLength the length of the rules, or -1 if the rules |
michael@0 | 531 | * are zero-terminated. |
michael@0 | 532 | * @param parseError a pointer to a UParseError struct to receive the |
michael@0 | 533 | * details of any parsing errors. This parameter may be NULL if no |
michael@0 | 534 | * parsing error details are desired. |
michael@0 | 535 | * @param status a pointer to the UErrorCode |
michael@0 | 536 | * @return a transliterator pointer that may be passed to other |
michael@0 | 537 | * utrans_xxx() functions, or NULL if the open call fails. |
michael@0 | 538 | * @deprecated ICU 2.8 Use utrans_openU() instead, see utrans.h |
michael@0 | 539 | */ |
michael@0 | 540 | U_DEPRECATED UTransliterator* U_EXPORT2 |
michael@0 | 541 | utrans_open(const char* id, |
michael@0 | 542 | UTransDirection dir, |
michael@0 | 543 | const UChar* rules, /* may be Null */ |
michael@0 | 544 | int32_t rulesLength, /* -1 if null-terminated */ |
michael@0 | 545 | UParseError* parseError, /* may be Null */ |
michael@0 | 546 | UErrorCode* status); |
michael@0 | 547 | |
michael@0 | 548 | /** |
michael@0 | 549 | * Deprecated, use utrans_getUnicodeID() instead. |
michael@0 | 550 | * Return the programmatic identifier for this transliterator. |
michael@0 | 551 | * If this identifier is passed to utrans_open(), it will open |
michael@0 | 552 | * a transliterator equivalent to this one, if the ID has been |
michael@0 | 553 | * registered. |
michael@0 | 554 | * @param trans the transliterator to return the ID of. |
michael@0 | 555 | * @param buf the buffer in which to receive the ID. This may be |
michael@0 | 556 | * NULL, in which case no characters are copied. |
michael@0 | 557 | * @param bufCapacity the capacity of the buffer. Ignored if buf is |
michael@0 | 558 | * NULL. |
michael@0 | 559 | * @return the actual length of the ID, not including |
michael@0 | 560 | * zero-termination. This may be greater than bufCapacity. |
michael@0 | 561 | * @deprecated ICU 2.8 Use utrans_getUnicodeID() instead, see utrans.h |
michael@0 | 562 | */ |
michael@0 | 563 | U_DEPRECATED int32_t U_EXPORT2 |
michael@0 | 564 | utrans_getID(const UTransliterator* trans, |
michael@0 | 565 | char* buf, |
michael@0 | 566 | int32_t bufCapacity); |
michael@0 | 567 | |
michael@0 | 568 | /** |
michael@0 | 569 | * Deprecated, use utrans_unregisterID() instead. |
michael@0 | 570 | * Unregister a transliterator from the system. After this call the |
michael@0 | 571 | * system will no longer recognize the given ID when passed to |
michael@0 | 572 | * utrans_open(). If the id is invalid then nothing is done. |
michael@0 | 573 | * |
michael@0 | 574 | * @param id a zero-terminated ID |
michael@0 | 575 | * @deprecated ICU 2.8 Use utrans_unregisterID() instead, see utrans.h |
michael@0 | 576 | */ |
michael@0 | 577 | U_DEPRECATED void U_EXPORT2 |
michael@0 | 578 | utrans_unregister(const char* id); |
michael@0 | 579 | |
michael@0 | 580 | /** |
michael@0 | 581 | * Deprecated, use utrans_openIDs() instead. |
michael@0 | 582 | * Return the ID of the index-th system transliterator. The result |
michael@0 | 583 | * is placed in the given buffer. If the given buffer is too small, |
michael@0 | 584 | * the initial substring is copied to buf. The result in buf is |
michael@0 | 585 | * always zero-terminated. |
michael@0 | 586 | * |
michael@0 | 587 | * @param index the number of the transliterator to return. Must |
michael@0 | 588 | * satisfy 0 <= index < utrans_countAvailableIDs(). If index is out |
michael@0 | 589 | * of range then it is treated as if it were 0. |
michael@0 | 590 | * @param buf the buffer in which to receive the ID. This may be |
michael@0 | 591 | * NULL, in which case no characters are copied. |
michael@0 | 592 | * @param bufCapacity the capacity of the buffer. Ignored if buf is |
michael@0 | 593 | * NULL. |
michael@0 | 594 | * @return the actual length of the index-th ID, not including |
michael@0 | 595 | * zero-termination. This may be greater than bufCapacity. |
michael@0 | 596 | * @deprecated ICU 2.8 Use utrans_openIDs() instead, see utrans.h |
michael@0 | 597 | */ |
michael@0 | 598 | U_DEPRECATED int32_t U_EXPORT2 |
michael@0 | 599 | utrans_getAvailableID(int32_t index, |
michael@0 | 600 | char* buf, |
michael@0 | 601 | int32_t bufCapacity); |
michael@0 | 602 | |
michael@0 | 603 | #endif /* U_HIDE_DEPRECATED_API */ |
michael@0 | 604 | |
michael@0 | 605 | #endif /* #if !UCONFIG_NO_TRANSLITERATION */ |
michael@0 | 606 | |
michael@0 | 607 | #endif |