utrans.h 25 KB

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