17777dab0Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 27777dab0Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 37777dab0Sopenharmony_ci/* 47777dab0Sopenharmony_ci******************************************************************************* 57777dab0Sopenharmony_ci* Copyright (C) 1997-2011,2014-2015 International Business Machines 67777dab0Sopenharmony_ci* Corporation and others. All Rights Reserved. 77777dab0Sopenharmony_ci******************************************************************************* 87777dab0Sopenharmony_ci* Date Name Description 97777dab0Sopenharmony_ci* 06/21/00 aliu Creation. 107777dab0Sopenharmony_ci******************************************************************************* 117777dab0Sopenharmony_ci*/ 127777dab0Sopenharmony_ci 137777dab0Sopenharmony_ci#ifndef UTRANS_H 147777dab0Sopenharmony_ci#define UTRANS_H 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci#include "unicode/utypes.h" 177777dab0Sopenharmony_ci 187777dab0Sopenharmony_ci#if !UCONFIG_NO_TRANSLITERATION 197777dab0Sopenharmony_ci 207777dab0Sopenharmony_ci#include "unicode/parseerr.h" 217777dab0Sopenharmony_ci#include "unicode/uenum.h" 227777dab0Sopenharmony_ci#include "unicode/uset.h" 237777dab0Sopenharmony_ci 247777dab0Sopenharmony_ci#if U_SHOW_CPLUSPLUS_API 257777dab0Sopenharmony_ci#include "unicode/localpointer.h" 267777dab0Sopenharmony_ci#endif // U_SHOW_CPLUSPLUS_API 277777dab0Sopenharmony_ci 287777dab0Sopenharmony_ci/******************************************************************** 297777dab0Sopenharmony_ci * General Notes 307777dab0Sopenharmony_ci ******************************************************************** 317777dab0Sopenharmony_ci */ 327777dab0Sopenharmony_ci/** 337777dab0Sopenharmony_ci * \file 347777dab0Sopenharmony_ci * \brief C API: Transliterator 357777dab0Sopenharmony_ci * 367777dab0Sopenharmony_ci * <h2> Transliteration </h2> 377777dab0Sopenharmony_ci * The data structures and functions described in this header provide 387777dab0Sopenharmony_ci * transliteration services. Transliteration services are implemented 397777dab0Sopenharmony_ci * as C++ classes. The comments and documentation in this header 407777dab0Sopenharmony_ci * assume the reader is familiar with the C++ headers translit.h and 417777dab0Sopenharmony_ci * associated documentation. 427777dab0Sopenharmony_ci * 437777dab0Sopenharmony_ci * A significant but incomplete subset of the C++ transliteration 447777dab0Sopenharmony_ci * services are available to C code through this header. In order to 457777dab0Sopenharmony_ci * access more complex transliteration services, refer to the C++ 467777dab0Sopenharmony_ci * headers and documentation. 477777dab0Sopenharmony_ci * 487777dab0Sopenharmony_ci * There are two sets of functions for working with transliterator IDs: 497777dab0Sopenharmony_ci * 507777dab0Sopenharmony_ci * An old, deprecated set uses char * IDs, which works for true and pure 517777dab0Sopenharmony_ci * identifiers that these APIs were designed for, 527777dab0Sopenharmony_ci * for example "Cyrillic-Latin". 537777dab0Sopenharmony_ci * It does not work when the ID contains filters ("[:Script=Cyrl:]") 547777dab0Sopenharmony_ci * or even a complete set of rules because then the ID string contains more 557777dab0Sopenharmony_ci * than just "invariant" characters (see utypes.h). 567777dab0Sopenharmony_ci * 577777dab0Sopenharmony_ci * A new set of functions replaces the old ones and uses UChar * IDs, 587777dab0Sopenharmony_ci * paralleling the UnicodeString IDs in the C++ API. (New in ICU 2.8.) 597777dab0Sopenharmony_ci */ 607777dab0Sopenharmony_ci 617777dab0Sopenharmony_ci/******************************************************************** 627777dab0Sopenharmony_ci * Data Structures 637777dab0Sopenharmony_ci ********************************************************************/ 647777dab0Sopenharmony_ci 657777dab0Sopenharmony_ci/** 667777dab0Sopenharmony_ci * An opaque transliterator for use in C. Open with utrans_openxxx() 677777dab0Sopenharmony_ci * and close with utrans_close() when done. Equivalent to the C++ class 687777dab0Sopenharmony_ci * Transliterator and its subclasses. 697777dab0Sopenharmony_ci * @see Transliterator 707777dab0Sopenharmony_ci * @stable ICU 2.0 717777dab0Sopenharmony_ci */ 727777dab0Sopenharmony_citypedef void* UTransliterator; 737777dab0Sopenharmony_ci 747777dab0Sopenharmony_ci/** 757777dab0Sopenharmony_ci * Direction constant indicating the direction in a transliterator, 767777dab0Sopenharmony_ci * e.g., the forward or reverse rules of a RuleBasedTransliterator. 777777dab0Sopenharmony_ci * Specified when a transliterator is opened. An "A-B" transliterator 787777dab0Sopenharmony_ci * transliterates A to B when operating in the forward direction, and 797777dab0Sopenharmony_ci * B to A when operating in the reverse direction. 807777dab0Sopenharmony_ci * @stable ICU 2.0 817777dab0Sopenharmony_ci */ 827777dab0Sopenharmony_citypedef enum UTransDirection { 837777dab0Sopenharmony_ci 847777dab0Sopenharmony_ci /** 857777dab0Sopenharmony_ci * UTRANS_FORWARD means from <source> to <target> for a 867777dab0Sopenharmony_ci * transliterator with ID <source>-<target>. For a transliterator 877777dab0Sopenharmony_ci * opened using a rule, it means forward direction rules, e.g., 887777dab0Sopenharmony_ci * "A > B". 897777dab0Sopenharmony_ci */ 907777dab0Sopenharmony_ci UTRANS_FORWARD, 917777dab0Sopenharmony_ci 927777dab0Sopenharmony_ci /** 937777dab0Sopenharmony_ci * UTRANS_REVERSE means from <target> to <source> for a 947777dab0Sopenharmony_ci * transliterator with ID <source>-<target>. For a transliterator 957777dab0Sopenharmony_ci * opened using a rule, it means reverse direction rules, e.g., 967777dab0Sopenharmony_ci * "A < B". 977777dab0Sopenharmony_ci */ 987777dab0Sopenharmony_ci UTRANS_REVERSE 997777dab0Sopenharmony_ci 1007777dab0Sopenharmony_ci} UTransDirection; 1017777dab0Sopenharmony_ci 1027777dab0Sopenharmony_ci/** 1037777dab0Sopenharmony_ci * Position structure for utrans_transIncremental() incremental 1047777dab0Sopenharmony_ci * transliteration. This structure defines two substrings of the text 1057777dab0Sopenharmony_ci * being transliterated. The first region, [contextStart, 1067777dab0Sopenharmony_ci * contextLimit), defines what characters the transliterator will read 1077777dab0Sopenharmony_ci * as context. The second region, [start, limit), defines what 1087777dab0Sopenharmony_ci * characters will actually be transliterated. The second region 1097777dab0Sopenharmony_ci * should be a subset of the first. 1107777dab0Sopenharmony_ci * 1117777dab0Sopenharmony_ci * <p>After a transliteration operation, some of the indices in this 1127777dab0Sopenharmony_ci * structure will be modified. See the field descriptions for 1137777dab0Sopenharmony_ci * details. 1147777dab0Sopenharmony_ci * 1157777dab0Sopenharmony_ci * <p>contextStart <= start <= limit <= contextLimit 1167777dab0Sopenharmony_ci * 1177777dab0Sopenharmony_ci * <p>Note: All index values in this structure must be at code point 1187777dab0Sopenharmony_ci * boundaries. That is, none of them may occur between two code units 1197777dab0Sopenharmony_ci * of a surrogate pair. If any index does split a surrogate pair, 1207777dab0Sopenharmony_ci * results are unspecified. 1217777dab0Sopenharmony_ci * 1227777dab0Sopenharmony_ci * @stable ICU 2.0 1237777dab0Sopenharmony_ci */ 1247777dab0Sopenharmony_citypedef struct UTransPosition { 1257777dab0Sopenharmony_ci 1267777dab0Sopenharmony_ci /** 1277777dab0Sopenharmony_ci * Beginning index, inclusive, of the context to be considered for 1287777dab0Sopenharmony_ci * a transliteration operation. The transliterator will ignore 1297777dab0Sopenharmony_ci * anything before this index. INPUT/OUTPUT parameter: This parameter 1307777dab0Sopenharmony_ci * is updated by a transliteration operation to reflect the maximum 1317777dab0Sopenharmony_ci * amount of antecontext needed by a transliterator. 1327777dab0Sopenharmony_ci * @stable ICU 2.4 1337777dab0Sopenharmony_ci */ 1347777dab0Sopenharmony_ci int32_t contextStart; 1357777dab0Sopenharmony_ci 1367777dab0Sopenharmony_ci /** 1377777dab0Sopenharmony_ci * Ending index, exclusive, of the context to be considered for a 1387777dab0Sopenharmony_ci * transliteration operation. The transliterator will ignore 1397777dab0Sopenharmony_ci * anything at or after this index. INPUT/OUTPUT parameter: This 1407777dab0Sopenharmony_ci * parameter is updated to reflect changes in the length of the 1417777dab0Sopenharmony_ci * text, but points to the same logical position in the text. 1427777dab0Sopenharmony_ci * @stable ICU 2.4 1437777dab0Sopenharmony_ci */ 1447777dab0Sopenharmony_ci int32_t contextLimit; 1457777dab0Sopenharmony_ci 1467777dab0Sopenharmony_ci /** 1477777dab0Sopenharmony_ci * Beginning index, inclusive, of the text to be transliterated. 1487777dab0Sopenharmony_ci * INPUT/OUTPUT parameter: This parameter is advanced past 1497777dab0Sopenharmony_ci * characters that have already been transliterated by a 1507777dab0Sopenharmony_ci * transliteration operation. 1517777dab0Sopenharmony_ci * @stable ICU 2.4 1527777dab0Sopenharmony_ci */ 1537777dab0Sopenharmony_ci int32_t start; 1547777dab0Sopenharmony_ci 1557777dab0Sopenharmony_ci /** 1567777dab0Sopenharmony_ci * Ending index, exclusive, of the text to be transliterated. 1577777dab0Sopenharmony_ci * INPUT/OUTPUT parameter: This parameter is updated to reflect 1587777dab0Sopenharmony_ci * changes in the length of the text, but points to the same 1597777dab0Sopenharmony_ci * logical position in the text. 1607777dab0Sopenharmony_ci * @stable ICU 2.4 1617777dab0Sopenharmony_ci */ 1627777dab0Sopenharmony_ci int32_t limit; 1637777dab0Sopenharmony_ci 1647777dab0Sopenharmony_ci} UTransPosition; 1657777dab0Sopenharmony_ci 1667777dab0Sopenharmony_ci/******************************************************************** 1677777dab0Sopenharmony_ci * General API 1687777dab0Sopenharmony_ci ********************************************************************/ 1697777dab0Sopenharmony_ci 1707777dab0Sopenharmony_ci/** 1717777dab0Sopenharmony_ci * Open a custom transliterator, given a custom rules string 1727777dab0Sopenharmony_ci * OR 1737777dab0Sopenharmony_ci * a system transliterator, given its ID. 1747777dab0Sopenharmony_ci * Any non-NULL result from this function should later be closed with 1757777dab0Sopenharmony_ci * utrans_close(). 1767777dab0Sopenharmony_ci * 1777777dab0Sopenharmony_ci * @param id a valid transliterator ID 1787777dab0Sopenharmony_ci * @param idLength the length of the ID string, or -1 if NUL-terminated 1797777dab0Sopenharmony_ci * @param dir the desired direction 1807777dab0Sopenharmony_ci * @param rules the transliterator rules. See the C++ header rbt.h for 1817777dab0Sopenharmony_ci * rules syntax. If NULL then a system transliterator matching 1827777dab0Sopenharmony_ci * the ID is returned. 1837777dab0Sopenharmony_ci * @param rulesLength the length of the rules, or -1 if the rules 1847777dab0Sopenharmony_ci * are NUL-terminated. 1857777dab0Sopenharmony_ci * @param parseError a pointer to a UParseError struct to receive the details 1867777dab0Sopenharmony_ci * of any parsing errors. This parameter may be NULL if no 1877777dab0Sopenharmony_ci * parsing error details are desired. 1887777dab0Sopenharmony_ci * @param pErrorCode a pointer to the UErrorCode 1897777dab0Sopenharmony_ci * @return a transliterator pointer that may be passed to other 1907777dab0Sopenharmony_ci * utrans_xxx() functions, or NULL if the open call fails. 1917777dab0Sopenharmony_ci * @stable ICU 2.8 1927777dab0Sopenharmony_ci */ 1937777dab0Sopenharmony_ciU_CAPI UTransliterator* U_EXPORT2 1947777dab0Sopenharmony_ciutrans_openU(const UChar *id, 1957777dab0Sopenharmony_ci int32_t idLength, 1967777dab0Sopenharmony_ci UTransDirection dir, 1977777dab0Sopenharmony_ci const UChar *rules, 1987777dab0Sopenharmony_ci int32_t rulesLength, 1997777dab0Sopenharmony_ci UParseError *parseError, 2007777dab0Sopenharmony_ci UErrorCode *pErrorCode); 2017777dab0Sopenharmony_ci 2027777dab0Sopenharmony_ci/** 2037777dab0Sopenharmony_ci * Open an inverse of an existing transliterator. For this to work, 2047777dab0Sopenharmony_ci * the inverse must be registered with the system. For example, if 2057777dab0Sopenharmony_ci * the Transliterator "A-B" is opened, and then its inverse is opened, 2067777dab0Sopenharmony_ci * the result is the Transliterator "B-A", if such a transliterator is 2077777dab0Sopenharmony_ci * registered with the system. Otherwise the result is NULL and a 2087777dab0Sopenharmony_ci * failing UErrorCode is set. Any non-NULL result from this function 2097777dab0Sopenharmony_ci * should later be closed with utrans_close(). 2107777dab0Sopenharmony_ci * 2117777dab0Sopenharmony_ci * @param trans the transliterator to open the inverse of. 2127777dab0Sopenharmony_ci * @param status a pointer to the UErrorCode 2137777dab0Sopenharmony_ci * @return a pointer to a newly-opened transliterator that is the 2147777dab0Sopenharmony_ci * inverse of trans, or NULL if the open call fails. 2157777dab0Sopenharmony_ci * @stable ICU 2.0 2167777dab0Sopenharmony_ci */ 2177777dab0Sopenharmony_ciU_CAPI UTransliterator* U_EXPORT2 2187777dab0Sopenharmony_ciutrans_openInverse(const UTransliterator* trans, 2197777dab0Sopenharmony_ci UErrorCode* status); 2207777dab0Sopenharmony_ci 2217777dab0Sopenharmony_ci/** 2227777dab0Sopenharmony_ci * Create a copy of a transliterator. Any non-NULL result from this 2237777dab0Sopenharmony_ci * function should later be closed with utrans_close(). 2247777dab0Sopenharmony_ci * 2257777dab0Sopenharmony_ci * @param trans the transliterator to be copied. 2267777dab0Sopenharmony_ci * @param status a pointer to the UErrorCode 2277777dab0Sopenharmony_ci * @return a transliterator pointer that may be passed to other 2287777dab0Sopenharmony_ci * utrans_xxx() functions, or NULL if the clone call fails. 2297777dab0Sopenharmony_ci * @stable ICU 2.0 2307777dab0Sopenharmony_ci */ 2317777dab0Sopenharmony_ciU_CAPI UTransliterator* U_EXPORT2 2327777dab0Sopenharmony_ciutrans_clone(const UTransliterator* trans, 2337777dab0Sopenharmony_ci UErrorCode* status); 2347777dab0Sopenharmony_ci 2357777dab0Sopenharmony_ci/** 2367777dab0Sopenharmony_ci * Close a transliterator. Any non-NULL pointer returned by 2377777dab0Sopenharmony_ci * utrans_openXxx() or utrans_clone() should eventually be closed. 2387777dab0Sopenharmony_ci * @param trans the transliterator to be closed. 2397777dab0Sopenharmony_ci * @stable ICU 2.0 2407777dab0Sopenharmony_ci */ 2417777dab0Sopenharmony_ciU_CAPI void U_EXPORT2 2427777dab0Sopenharmony_ciutrans_close(UTransliterator* trans); 2437777dab0Sopenharmony_ci 2447777dab0Sopenharmony_ci#if U_SHOW_CPLUSPLUS_API 2457777dab0Sopenharmony_ci 2467777dab0Sopenharmony_ciU_NAMESPACE_BEGIN 2477777dab0Sopenharmony_ci 2487777dab0Sopenharmony_ci/** 2497777dab0Sopenharmony_ci * \class LocalUTransliteratorPointer 2507777dab0Sopenharmony_ci * "Smart pointer" class, closes a UTransliterator via utrans_close(). 2517777dab0Sopenharmony_ci * For most methods see the LocalPointerBase base class. 2527777dab0Sopenharmony_ci * 2537777dab0Sopenharmony_ci * @see LocalPointerBase 2547777dab0Sopenharmony_ci * @see LocalPointer 2557777dab0Sopenharmony_ci * @stable ICU 4.4 2567777dab0Sopenharmony_ci */ 2577777dab0Sopenharmony_ciU_DEFINE_LOCAL_OPEN_POINTER(LocalUTransliteratorPointer, UTransliterator, utrans_close); 2587777dab0Sopenharmony_ci 2597777dab0Sopenharmony_ciU_NAMESPACE_END 2607777dab0Sopenharmony_ci 2617777dab0Sopenharmony_ci#endif 2627777dab0Sopenharmony_ci 2637777dab0Sopenharmony_ci/** 2647777dab0Sopenharmony_ci * Return the programmatic identifier for this transliterator. 2657777dab0Sopenharmony_ci * If this identifier is passed to utrans_openU(), it will open 2667777dab0Sopenharmony_ci * a transliterator equivalent to this one, if the ID has been 2677777dab0Sopenharmony_ci * registered. 2687777dab0Sopenharmony_ci * 2697777dab0Sopenharmony_ci * @param trans the transliterator to return the ID of. 2707777dab0Sopenharmony_ci * @param resultLength pointer to an output variable receiving the length 2717777dab0Sopenharmony_ci * of the ID string; can be NULL 2727777dab0Sopenharmony_ci * @return the NUL-terminated ID string. This pointer remains 2737777dab0Sopenharmony_ci * valid until utrans_close() is called on this transliterator. 2747777dab0Sopenharmony_ci * 2757777dab0Sopenharmony_ci * @stable ICU 2.8 2767777dab0Sopenharmony_ci */ 2777777dab0Sopenharmony_ciU_CAPI const UChar * U_EXPORT2 2787777dab0Sopenharmony_ciutrans_getUnicodeID(const UTransliterator *trans, 2797777dab0Sopenharmony_ci int32_t *resultLength); 2807777dab0Sopenharmony_ci 2817777dab0Sopenharmony_ci/** 2827777dab0Sopenharmony_ci * Register an open transliterator with the system. When 2837777dab0Sopenharmony_ci * utrans_open() is called with an ID string that is equal to that 2847777dab0Sopenharmony_ci * returned by utrans_getID(adoptedTrans,...), then 2857777dab0Sopenharmony_ci * utrans_clone(adoptedTrans,...) is returned. 2867777dab0Sopenharmony_ci * 2877777dab0Sopenharmony_ci * <p>NOTE: After this call the system owns the adoptedTrans and will 2887777dab0Sopenharmony_ci * close it. The user must not call utrans_close() on adoptedTrans. 2897777dab0Sopenharmony_ci * 2907777dab0Sopenharmony_ci * @param adoptedTrans a transliterator, typically the result of 2917777dab0Sopenharmony_ci * utrans_openRules(), to be registered with the system. 2927777dab0Sopenharmony_ci * @param status a pointer to the UErrorCode 2937777dab0Sopenharmony_ci * @stable ICU 2.0 2947777dab0Sopenharmony_ci */ 2957777dab0Sopenharmony_ciU_CAPI void U_EXPORT2 2967777dab0Sopenharmony_ciutrans_register(UTransliterator* adoptedTrans, 2977777dab0Sopenharmony_ci UErrorCode* status); 2987777dab0Sopenharmony_ci 2997777dab0Sopenharmony_ci/** 3007777dab0Sopenharmony_ci * Unregister a transliterator from the system. After this call the 3017777dab0Sopenharmony_ci * system will no longer recognize the given ID when passed to 3027777dab0Sopenharmony_ci * utrans_open(). If the ID is invalid then nothing is done. 3037777dab0Sopenharmony_ci * 3047777dab0Sopenharmony_ci * @param id an ID to unregister 3057777dab0Sopenharmony_ci * @param idLength the length of id, or -1 if id is zero-terminated 3067777dab0Sopenharmony_ci * @stable ICU 2.8 3077777dab0Sopenharmony_ci */ 3087777dab0Sopenharmony_ciU_CAPI void U_EXPORT2 3097777dab0Sopenharmony_ciutrans_unregisterID(const UChar* id, int32_t idLength); 3107777dab0Sopenharmony_ci 3117777dab0Sopenharmony_ci/** 3127777dab0Sopenharmony_ci * Set the filter used by a transliterator. A filter can be used to 3137777dab0Sopenharmony_ci * make the transliterator pass certain characters through untouched. 3147777dab0Sopenharmony_ci * The filter is expressed using a UnicodeSet pattern. If the 3157777dab0Sopenharmony_ci * filterPattern is NULL or the empty string, then the transliterator 3167777dab0Sopenharmony_ci * will be reset to use no filter. 3177777dab0Sopenharmony_ci * 3187777dab0Sopenharmony_ci * @param trans the transliterator 3197777dab0Sopenharmony_ci * @param filterPattern a pattern string, in the form accepted by 3207777dab0Sopenharmony_ci * UnicodeSet, specifying which characters to apply the 3217777dab0Sopenharmony_ci * transliteration to. May be NULL or the empty string to indicate no 3227777dab0Sopenharmony_ci * filter. 3237777dab0Sopenharmony_ci * @param filterPatternLen the length of filterPattern, or -1 if 3247777dab0Sopenharmony_ci * filterPattern is zero-terminated 3257777dab0Sopenharmony_ci * @param status a pointer to the UErrorCode 3267777dab0Sopenharmony_ci * @see UnicodeSet 3277777dab0Sopenharmony_ci * @stable ICU 2.0 3287777dab0Sopenharmony_ci */ 3297777dab0Sopenharmony_ciU_CAPI void U_EXPORT2 3307777dab0Sopenharmony_ciutrans_setFilter(UTransliterator* trans, 3317777dab0Sopenharmony_ci const UChar* filterPattern, 3327777dab0Sopenharmony_ci int32_t filterPatternLen, 3337777dab0Sopenharmony_ci UErrorCode* status); 3347777dab0Sopenharmony_ci 3357777dab0Sopenharmony_ci/** 3367777dab0Sopenharmony_ci * Return the number of system transliterators. 3377777dab0Sopenharmony_ci * It is recommended to use utrans_openIDs() instead. 3387777dab0Sopenharmony_ci * 3397777dab0Sopenharmony_ci * @return the number of system transliterators. 3407777dab0Sopenharmony_ci * @stable ICU 2.0 3417777dab0Sopenharmony_ci */ 3427777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2 3437777dab0Sopenharmony_ciutrans_countAvailableIDs(void); 3447777dab0Sopenharmony_ci 3457777dab0Sopenharmony_ci/** 3467777dab0Sopenharmony_ci * Return a UEnumeration for the available transliterators. 3477777dab0Sopenharmony_ci * 3487777dab0Sopenharmony_ci * @param pErrorCode Pointer to the UErrorCode in/out parameter. 3497777dab0Sopenharmony_ci * @return UEnumeration for the available transliterators. 3507777dab0Sopenharmony_ci * Close with uenum_close(). 3517777dab0Sopenharmony_ci * 3527777dab0Sopenharmony_ci * @stable ICU 2.8 3537777dab0Sopenharmony_ci */ 3547777dab0Sopenharmony_ciU_CAPI UEnumeration * U_EXPORT2 3557777dab0Sopenharmony_ciutrans_openIDs(UErrorCode *pErrorCode); 3567777dab0Sopenharmony_ci 3577777dab0Sopenharmony_ci/******************************************************************** 3587777dab0Sopenharmony_ci * Transliteration API 3597777dab0Sopenharmony_ci ********************************************************************/ 3607777dab0Sopenharmony_ci 3617777dab0Sopenharmony_ci/** 3627777dab0Sopenharmony_ci * Transliterate a segment of a UChar* string. The string is passed 3637777dab0Sopenharmony_ci * in in a UChar* buffer. The string is modified in place. If the 3647777dab0Sopenharmony_ci * result is longer than textCapacity, it is truncated. The actual 3657777dab0Sopenharmony_ci * length of the result is returned in *textLength, if textLength is 3667777dab0Sopenharmony_ci * non-NULL. *textLength may be greater than textCapacity, but only 3677777dab0Sopenharmony_ci * textCapacity UChars will be written to *text, including the zero 3687777dab0Sopenharmony_ci * terminator. 3697777dab0Sopenharmony_ci * 3707777dab0Sopenharmony_ci * @param trans the transliterator 3717777dab0Sopenharmony_ci * @param text a pointer to a buffer containing the text to be 3727777dab0Sopenharmony_ci * transliterated on input and the result text on output. 3737777dab0Sopenharmony_ci * @param textLength a pointer to the length of the string in text. 3747777dab0Sopenharmony_ci * If the length is -1 then the string is assumed to be 3757777dab0Sopenharmony_ci * zero-terminated. Upon return, the new length is stored in 3767777dab0Sopenharmony_ci * *textLength. If textLength is NULL then the string is assumed to 3777777dab0Sopenharmony_ci * be zero-terminated. 3787777dab0Sopenharmony_ci * @param textCapacity the length of the text buffer 3797777dab0Sopenharmony_ci * @param start the beginning index, inclusive; <code>0 <= start <= 3807777dab0Sopenharmony_ci * limit</code>. 3817777dab0Sopenharmony_ci * @param limit pointer to the ending index, exclusive; <code>start <= 3827777dab0Sopenharmony_ci * limit <= repFunc->length(rep)</code>. Upon return, *limit will 3837777dab0Sopenharmony_ci * contain the new limit index. The text previously occupying 3847777dab0Sopenharmony_ci * <code>[start, limit)</code> has been transliterated, possibly to a 3857777dab0Sopenharmony_ci * string of a different length, at <code>[start, 3867777dab0Sopenharmony_ci * </code><em>new-limit</em><code>)</code>, where <em>new-limit</em> 3877777dab0Sopenharmony_ci * is the return value. 3887777dab0Sopenharmony_ci * @param status a pointer to the UErrorCode 3897777dab0Sopenharmony_ci * @stable ICU 2.0 3907777dab0Sopenharmony_ci */ 3917777dab0Sopenharmony_ciU_CAPI void U_EXPORT2 3927777dab0Sopenharmony_ciutrans_transUChars(const UTransliterator* trans, 3937777dab0Sopenharmony_ci UChar* text, 3947777dab0Sopenharmony_ci int32_t* textLength, 3957777dab0Sopenharmony_ci int32_t textCapacity, 3967777dab0Sopenharmony_ci int32_t start, 3977777dab0Sopenharmony_ci int32_t* limit, 3987777dab0Sopenharmony_ci UErrorCode* status); 3997777dab0Sopenharmony_ci 4007777dab0Sopenharmony_ci/** 4017777dab0Sopenharmony_ci * Transliterate the portion of the UChar* text buffer that can be 4027777dab0Sopenharmony_ci * transliterated unambiguously. See utrans_transIncremental(). The 4037777dab0Sopenharmony_ci * string is passed in in a UChar* buffer. The string is modified in 4047777dab0Sopenharmony_ci * place. If the result is longer than textCapacity, it is truncated. 4057777dab0Sopenharmony_ci * The actual length of the result is returned in *textLength, if 4067777dab0Sopenharmony_ci * textLength is non-NULL. *textLength may be greater than 4077777dab0Sopenharmony_ci * textCapacity, but only textCapacity UChars will be written to 4087777dab0Sopenharmony_ci * *text, including the zero terminator. See utrans_transIncremental() 4097777dab0Sopenharmony_ci * for usage details. 4107777dab0Sopenharmony_ci * 4117777dab0Sopenharmony_ci * @param trans the transliterator 4127777dab0Sopenharmony_ci * @param text a pointer to a buffer containing the text to be 4137777dab0Sopenharmony_ci * transliterated on input and the result text on output. 4147777dab0Sopenharmony_ci * @param textLength a pointer to the length of the string in text. 4157777dab0Sopenharmony_ci * If the length is -1 then the string is assumed to be 4167777dab0Sopenharmony_ci * zero-terminated. Upon return, the new length is stored in 4177777dab0Sopenharmony_ci * *textLength. If textLength is NULL then the string is assumed to 4187777dab0Sopenharmony_ci * be zero-terminated. 4197777dab0Sopenharmony_ci * @param textCapacity the length of the text buffer 4207777dab0Sopenharmony_ci * @param pos a struct containing the start and limit indices of the 4217777dab0Sopenharmony_ci * text to be read and the text to be transliterated 4227777dab0Sopenharmony_ci * @param status a pointer to the UErrorCode 4237777dab0Sopenharmony_ci * @see utrans_transIncremental 4247777dab0Sopenharmony_ci * @stable ICU 2.0 4257777dab0Sopenharmony_ci */ 4267777dab0Sopenharmony_ciU_CAPI void U_EXPORT2 4277777dab0Sopenharmony_ciutrans_transIncrementalUChars(const UTransliterator* trans, 4287777dab0Sopenharmony_ci UChar* text, 4297777dab0Sopenharmony_ci int32_t* textLength, 4307777dab0Sopenharmony_ci int32_t textCapacity, 4317777dab0Sopenharmony_ci UTransPosition* pos, 4327777dab0Sopenharmony_ci UErrorCode* status); 4337777dab0Sopenharmony_ci 4347777dab0Sopenharmony_ci/** 4357777dab0Sopenharmony_ci * Create a rule string that can be passed to utrans_openU to recreate this 4367777dab0Sopenharmony_ci * transliterator. 4377777dab0Sopenharmony_ci * 4387777dab0Sopenharmony_ci * @param trans The transliterator 4397777dab0Sopenharmony_ci * @param escapeUnprintable if true then convert unprintable characters to their 4407777dab0Sopenharmony_ci * hex escape representations, \\uxxxx or \\Uxxxxxxxx. 4417777dab0Sopenharmony_ci * Unprintable characters are those other than 4427777dab0Sopenharmony_ci * U+000A, U+0020..U+007E. 4437777dab0Sopenharmony_ci * @param result A pointer to a buffer to receive the rules. 4447777dab0Sopenharmony_ci * @param resultLength The maximum size of result. 4457777dab0Sopenharmony_ci * @param status A pointer to the UErrorCode. In case of error status, the 4467777dab0Sopenharmony_ci * contents of result are undefined. 4477777dab0Sopenharmony_ci * @return int32_t The length of the rule string (may be greater than resultLength, 4487777dab0Sopenharmony_ci * in which case an error is returned). 4497777dab0Sopenharmony_ci * @stable ICU 53 4507777dab0Sopenharmony_ci */ 4517777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2 4527777dab0Sopenharmony_ciutrans_toRules( const UTransliterator* trans, 4537777dab0Sopenharmony_ci UBool escapeUnprintable, 4547777dab0Sopenharmony_ci UChar* result, int32_t resultLength, 4557777dab0Sopenharmony_ci UErrorCode* status); 4567777dab0Sopenharmony_ci 4577777dab0Sopenharmony_ci/** 4587777dab0Sopenharmony_ci * Returns the set of all characters that may be modified in the input text by 4597777dab0Sopenharmony_ci * this UTransliterator, optionally ignoring the transliterator's current filter. 4607777dab0Sopenharmony_ci * @param trans The transliterator. 4617777dab0Sopenharmony_ci * @param ignoreFilter If false, the returned set incorporates the 4627777dab0Sopenharmony_ci * UTransliterator's current filter; if the filter is changed, 4637777dab0Sopenharmony_ci * the return value of this function will change. If true, the 4647777dab0Sopenharmony_ci * returned set ignores the effect of the UTransliterator's 4657777dab0Sopenharmony_ci * current filter. 4667777dab0Sopenharmony_ci * @param fillIn Pointer to a USet object to receive the modifiable characters 4677777dab0Sopenharmony_ci * set. Previous contents of fillIn are lost. <em>If fillIn is 4687777dab0Sopenharmony_ci * NULL, then a new USet is created and returned. The caller 4697777dab0Sopenharmony_ci * owns the result and must dispose of it by calling uset_close.</em> 4707777dab0Sopenharmony_ci * @param status A pointer to the UErrorCode. 4717777dab0Sopenharmony_ci * @return USet* Either fillIn, or if fillIn is NULL, a pointer to a 4727777dab0Sopenharmony_ci * newly-allocated USet that the user must close. In case of 4737777dab0Sopenharmony_ci * error, NULL is returned. 4747777dab0Sopenharmony_ci * @stable ICU 53 4757777dab0Sopenharmony_ci */ 4767777dab0Sopenharmony_ciU_CAPI USet* U_EXPORT2 4777777dab0Sopenharmony_ciutrans_getSourceSet(const UTransliterator* trans, 4787777dab0Sopenharmony_ci UBool ignoreFilter, 4797777dab0Sopenharmony_ci USet* fillIn, 4807777dab0Sopenharmony_ci UErrorCode* status); 4817777dab0Sopenharmony_ci 4827777dab0Sopenharmony_ci/* deprecated API ----------------------------------------------------------- */ 4837777dab0Sopenharmony_ci 4847777dab0Sopenharmony_ci#ifndef U_HIDE_DEPRECATED_API 4857777dab0Sopenharmony_ci 4867777dab0Sopenharmony_ci/* see utrans.h documentation for why these functions are deprecated */ 4877777dab0Sopenharmony_ci 4887777dab0Sopenharmony_ci 4897777dab0Sopenharmony_ci 4907777dab0Sopenharmony_ci#endif /* U_HIDE_DEPRECATED_API */ 4917777dab0Sopenharmony_ci 4927777dab0Sopenharmony_ci#endif /* #if !UCONFIG_NO_TRANSLITERATION */ 4937777dab0Sopenharmony_ci 4947777dab0Sopenharmony_ci#endif 495