utrans.h 26 KB

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