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