utrans.h 26 KB

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