xref: /aosp_15_r20/external/icu/libandroidicu/include/unicode/ubiditransform.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker /*
2*0e209d39SAndroid Build Coastguard Worker ******************************************************************************
3*0e209d39SAndroid Build Coastguard Worker *
4*0e209d39SAndroid Build Coastguard Worker * © 2016 and later: Unicode, Inc. and others.
5*0e209d39SAndroid Build Coastguard Worker * License & terms of use: http://www.unicode.org/copyright.html
6*0e209d39SAndroid Build Coastguard Worker *
7*0e209d39SAndroid Build Coastguard Worker ******************************************************************************
8*0e209d39SAndroid Build Coastguard Worker *   file name:  ubiditransform.h
9*0e209d39SAndroid Build Coastguard Worker *   encoding:   UTF-8
10*0e209d39SAndroid Build Coastguard Worker *   tab size:   8 (not used)
11*0e209d39SAndroid Build Coastguard Worker *   indentation:4
12*0e209d39SAndroid Build Coastguard Worker *
13*0e209d39SAndroid Build Coastguard Worker *   created on: 2016jul24
14*0e209d39SAndroid Build Coastguard Worker *   created by: Lina Kemmel
15*0e209d39SAndroid Build Coastguard Worker *
16*0e209d39SAndroid Build Coastguard Worker */
17*0e209d39SAndroid Build Coastguard Worker 
18*0e209d39SAndroid Build Coastguard Worker #ifndef UBIDITRANSFORM_H
19*0e209d39SAndroid Build Coastguard Worker #define UBIDITRANSFORM_H
20*0e209d39SAndroid Build Coastguard Worker 
21*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
22*0e209d39SAndroid Build Coastguard Worker #include "unicode/ubidi.h"
23*0e209d39SAndroid Build Coastguard Worker #include "unicode/uchar.h"
24*0e209d39SAndroid Build Coastguard Worker 
25*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
26*0e209d39SAndroid Build Coastguard Worker #include "unicode/localpointer.h"
27*0e209d39SAndroid Build Coastguard Worker #endif   // U_SHOW_CPLUSPLUS_API
28*0e209d39SAndroid Build Coastguard Worker 
29*0e209d39SAndroid Build Coastguard Worker /**
30*0e209d39SAndroid Build Coastguard Worker  * \file
31*0e209d39SAndroid Build Coastguard Worker  * \brief C API: Bidi Transformations
32*0e209d39SAndroid Build Coastguard Worker  */
33*0e209d39SAndroid Build Coastguard Worker 
34*0e209d39SAndroid Build Coastguard Worker /**
35*0e209d39SAndroid Build Coastguard Worker  * `UBiDiOrder` indicates the order of text.
36*0e209d39SAndroid Build Coastguard Worker  *
37*0e209d39SAndroid Build Coastguard Worker  * This bidi transformation engine supports all possible combinations (4 in
38*0e209d39SAndroid Build Coastguard Worker  * total) of input and output text order:
39*0e209d39SAndroid Build Coastguard Worker  *
40*0e209d39SAndroid Build Coastguard Worker  *   - <logical input, visual output>: unless the output direction is RTL, this
41*0e209d39SAndroid Build Coastguard Worker  *     corresponds to a normal operation of the Bidi algorithm as described in the
42*0e209d39SAndroid Build Coastguard Worker  *     Unicode Technical Report and implemented by `UBiDi` when the
43*0e209d39SAndroid Build Coastguard Worker  *     reordering mode is set to `UBIDI_REORDER_DEFAULT`. Visual RTL
44*0e209d39SAndroid Build Coastguard Worker  *     mode is not supported by `UBiDi` and is accomplished through
45*0e209d39SAndroid Build Coastguard Worker  *     reversing a visual LTR string,
46*0e209d39SAndroid Build Coastguard Worker  *
47*0e209d39SAndroid Build Coastguard Worker  *   - <visual input, logical output>: unless the input direction is RTL, this
48*0e209d39SAndroid Build Coastguard Worker  *     corresponds to an "inverse bidi algorithm" in `UBiDi` with the
49*0e209d39SAndroid Build Coastguard Worker  *     reordering mode set to `UBIDI_REORDER_INVERSE_LIKE_DIRECT`.
50*0e209d39SAndroid Build Coastguard Worker  *     Visual RTL mode is not not supported by `UBiDi` and is
51*0e209d39SAndroid Build Coastguard Worker  *     accomplished through reversing a visual LTR string,
52*0e209d39SAndroid Build Coastguard Worker  *
53*0e209d39SAndroid Build Coastguard Worker  *   - <logical input, logical output>: if the input and output base directions
54*0e209d39SAndroid Build Coastguard Worker  *     mismatch, this corresponds to the `UBiDi` implementation with the
55*0e209d39SAndroid Build Coastguard Worker  *     reordering mode set to `UBIDI_REORDER_RUNS_ONLY`; and if the
56*0e209d39SAndroid Build Coastguard Worker  *     input and output base directions are identical, the transformation engine
57*0e209d39SAndroid Build Coastguard Worker  *     will only handle character mirroring and Arabic shaping operations without
58*0e209d39SAndroid Build Coastguard Worker  *     reordering,
59*0e209d39SAndroid Build Coastguard Worker  *
60*0e209d39SAndroid Build Coastguard Worker  *   - <visual input, visual output>: this reordering mode is not supported by
61*0e209d39SAndroid Build Coastguard Worker  *     the `UBiDi` engine; it implies character mirroring, Arabic
62*0e209d39SAndroid Build Coastguard Worker  *     shaping, and - if the input/output base directions mismatch -  string
63*0e209d39SAndroid Build Coastguard Worker  *     reverse operations.
64*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setInverse
65*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setReorderingMode
66*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_REORDER_DEFAULT
67*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_REORDER_INVERSE_LIKE_DIRECT
68*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_REORDER_RUNS_ONLY
69*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 58
70*0e209d39SAndroid Build Coastguard Worker  */
71*0e209d39SAndroid Build Coastguard Worker typedef enum {
72*0e209d39SAndroid Build Coastguard Worker     /** 0: Constant indicating a logical order.
73*0e209d39SAndroid Build Coastguard Worker       * This is the default for input text.
74*0e209d39SAndroid Build Coastguard Worker       * @stable ICU 58
75*0e209d39SAndroid Build Coastguard Worker       */
76*0e209d39SAndroid Build Coastguard Worker     UBIDI_LOGICAL = 0,
77*0e209d39SAndroid Build Coastguard Worker     /** 1: Constant indicating a visual order.
78*0e209d39SAndroid Build Coastguard Worker       * This is a default for output text.
79*0e209d39SAndroid Build Coastguard Worker       * @stable ICU 58
80*0e209d39SAndroid Build Coastguard Worker       */
81*0e209d39SAndroid Build Coastguard Worker     UBIDI_VISUAL
82*0e209d39SAndroid Build Coastguard Worker } UBiDiOrder;
83*0e209d39SAndroid Build Coastguard Worker 
84*0e209d39SAndroid Build Coastguard Worker /**
85*0e209d39SAndroid Build Coastguard Worker  * <code>UBiDiMirroring</code> indicates whether or not characters with the
86*0e209d39SAndroid Build Coastguard Worker  * "mirrored" property in RTL runs should be replaced with their mirror-image
87*0e209d39SAndroid Build Coastguard Worker  * counterparts.
88*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_DO_MIRRORING
89*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setReorderingOptions
90*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_writeReordered
91*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_writeReverse
92*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 58
93*0e209d39SAndroid Build Coastguard Worker  */
94*0e209d39SAndroid Build Coastguard Worker typedef enum {
95*0e209d39SAndroid Build Coastguard Worker     /** 0: Constant indicating that character mirroring should not be
96*0e209d39SAndroid Build Coastguard Worker       * performed.
97*0e209d39SAndroid Build Coastguard Worker       * This is the default.
98*0e209d39SAndroid Build Coastguard Worker       * @stable ICU 58
99*0e209d39SAndroid Build Coastguard Worker       */
100*0e209d39SAndroid Build Coastguard Worker     UBIDI_MIRRORING_OFF = 0,
101*0e209d39SAndroid Build Coastguard Worker     /** 1: Constant indicating that character mirroring should be performed.
102*0e209d39SAndroid Build Coastguard Worker       * This corresponds to calling <code>ubidi_writeReordered</code> or
103*0e209d39SAndroid Build Coastguard Worker       * <code>ubidi_writeReverse</code> with the
104*0e209d39SAndroid Build Coastguard Worker       * <code>UBIDI_DO_MIRRORING</code> option bit set.
105*0e209d39SAndroid Build Coastguard Worker       * @stable ICU 58
106*0e209d39SAndroid Build Coastguard Worker       */
107*0e209d39SAndroid Build Coastguard Worker     UBIDI_MIRRORING_ON
108*0e209d39SAndroid Build Coastguard Worker } UBiDiMirroring;
109*0e209d39SAndroid Build Coastguard Worker 
110*0e209d39SAndroid Build Coastguard Worker /**
111*0e209d39SAndroid Build Coastguard Worker  * Forward declaration of the <code>UBiDiTransform</code> structure that stores
112*0e209d39SAndroid Build Coastguard Worker  * information used by the layout transformation engine.
113*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 58
114*0e209d39SAndroid Build Coastguard Worker  */
115*0e209d39SAndroid Build Coastguard Worker typedef struct UBiDiTransform UBiDiTransform;
116*0e209d39SAndroid Build Coastguard Worker 
117*0e209d39SAndroid Build Coastguard Worker /**
118*0e209d39SAndroid Build Coastguard Worker  * Performs transformation of text from the bidi layout defined by the input
119*0e209d39SAndroid Build Coastguard Worker  * ordering scheme to the bidi layout defined by the output ordering scheme,
120*0e209d39SAndroid Build Coastguard Worker  * and applies character mirroring and Arabic shaping operations.<p>
121*0e209d39SAndroid Build Coastguard Worker  * In terms of <code>UBiDi</code>, such a transformation implies:
122*0e209d39SAndroid Build Coastguard Worker  * <ul>
123*0e209d39SAndroid Build Coastguard Worker  * <li>calling <code>ubidi_setReorderingMode</code> as needed (when the
124*0e209d39SAndroid Build Coastguard Worker  * reordering mode is other than normal),</li>
125*0e209d39SAndroid Build Coastguard Worker  * <li>calling <code>ubidi_setInverse</code> as needed (when text should be
126*0e209d39SAndroid Build Coastguard Worker  * transformed from a visual to a logical form),</li>
127*0e209d39SAndroid Build Coastguard Worker  * <li>resolving embedding levels of each character in the input text by
128*0e209d39SAndroid Build Coastguard Worker  * calling <code>ubidi_setPara</code>,</li>
129*0e209d39SAndroid Build Coastguard Worker  * <li>reordering the characters based on the computed embedding levels, also
130*0e209d39SAndroid Build Coastguard Worker  * performing character mirroring as needed, and streaming the result to the
131*0e209d39SAndroid Build Coastguard Worker  * output, by calling <code>ubidi_writeReordered</code>,</li>
132*0e209d39SAndroid Build Coastguard Worker  * <li>performing Arabic digit and letter shaping on the output text by calling
133*0e209d39SAndroid Build Coastguard Worker  * <code>u_shapeArabic</code>.</li>
134*0e209d39SAndroid Build Coastguard Worker  * </ul>
135*0e209d39SAndroid Build Coastguard Worker  * An "ordering scheme" encompasses the base direction and the order of text,
136*0e209d39SAndroid Build Coastguard Worker  * and these characteristics must be defined by the caller for both input and
137*0e209d39SAndroid Build Coastguard Worker  * output explicitly .<p>
138*0e209d39SAndroid Build Coastguard Worker  * There are 36 possible combinations of <input, output> ordering schemes,
139*0e209d39SAndroid Build Coastguard Worker  * which are partially supported by <code>UBiDi</code> already. Examples of the
140*0e209d39SAndroid Build Coastguard Worker  * currently supported combinations:
141*0e209d39SAndroid Build Coastguard Worker  * <ul>
142*0e209d39SAndroid Build Coastguard Worker  * <li><Logical LTR, Visual LTR>: this is equivalent to calling
143*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setPara</code> with <code>paraLevel == UBIDI_LTR</code>,</li>
144*0e209d39SAndroid Build Coastguard Worker  * <li><Logical RTL, Visual LTR>: this is equivalent to calling
145*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setPara</code> with <code>paraLevel == UBIDI_RTL</code>,</li>
146*0e209d39SAndroid Build Coastguard Worker  * <li><Logical Default ("Auto") LTR, Visual LTR>: this is equivalent to
147*0e209d39SAndroid Build Coastguard Worker  * calling <code>ubidi_setPara</code> with
148*0e209d39SAndroid Build Coastguard Worker  * <code>paraLevel == UBIDI_DEFAULT_LTR</code>,</li>
149*0e209d39SAndroid Build Coastguard Worker  * <li><Logical Default ("Auto") RTL, Visual LTR>: this is equivalent to
150*0e209d39SAndroid Build Coastguard Worker  * calling <code>ubidi_setPara</code> with
151*0e209d39SAndroid Build Coastguard Worker  * <code>paraLevel == UBIDI_DEFAULT_RTL</code>,</li>
152*0e209d39SAndroid Build Coastguard Worker  * <li><Visual LTR, Logical LTR>: this is equivalent to
153*0e209d39SAndroid Build Coastguard Worker  * calling <code>ubidi_setInverse(UBiDi*, true)</code> and then
154*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setPara</code> with <code>paraLevel == UBIDI_LTR</code>,</li>
155*0e209d39SAndroid Build Coastguard Worker  * <li><Visual LTR, Logical RTL>: this is equivalent to
156*0e209d39SAndroid Build Coastguard Worker  * calling <code>ubidi_setInverse(UBiDi*, true)</code> and then
157*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setPara</code> with <code>paraLevel == UBIDI_RTL</code>.</li>
158*0e209d39SAndroid Build Coastguard Worker  * </ul>
159*0e209d39SAndroid Build Coastguard Worker  * All combinations that involve the Visual RTL scheme are unsupported by
160*0e209d39SAndroid Build Coastguard Worker  * <code>UBiDi</code>, for instance:
161*0e209d39SAndroid Build Coastguard Worker  * <ul>
162*0e209d39SAndroid Build Coastguard Worker  * <li><Logical LTR, Visual RTL>,</li>
163*0e209d39SAndroid Build Coastguard Worker  * <li><Visual RTL, Logical RTL>.</li>
164*0e209d39SAndroid Build Coastguard Worker  * </ul>
165*0e209d39SAndroid Build Coastguard Worker  * <p>Example of usage of the transformation engine:<br>
166*0e209d39SAndroid Build Coastguard Worker  * <pre>
167*0e209d39SAndroid Build Coastguard Worker  * \code
168*0e209d39SAndroid Build Coastguard Worker  * UChar text1[] = {'a', 'b', 'c', 0x0625, '1', 0};
169*0e209d39SAndroid Build Coastguard Worker  * UChar text2[] = {'a', 'b', 'c', 0x0625, '1', 0};
170*0e209d39SAndroid Build Coastguard Worker  * UErrorCode errorCode = U_ZERO_ERROR;
171*0e209d39SAndroid Build Coastguard Worker  * // Run a transformation.
172*0e209d39SAndroid Build Coastguard Worker  * ubiditransform_transform(pBidiTransform,
173*0e209d39SAndroid Build Coastguard Worker  *          text1, -1, text2, -1,
174*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_LTR, UBIDI_VISUAL,
175*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_RTL, UBIDI_LOGICAL,
176*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_MIRRORING_OFF,
177*0e209d39SAndroid Build Coastguard Worker  *          U_SHAPE_DIGITS_AN2EN | U_SHAPE_DIGIT_TYPE_AN_EXTENDED,
178*0e209d39SAndroid Build Coastguard Worker  *          &errorCode);
179*0e209d39SAndroid Build Coastguard Worker  * // Do something with text2.
180*0e209d39SAndroid Build Coastguard Worker  *  text2[4] = '2';
181*0e209d39SAndroid Build Coastguard Worker  * // Run a reverse transformation.
182*0e209d39SAndroid Build Coastguard Worker  * ubiditransform_transform(pBidiTransform,
183*0e209d39SAndroid Build Coastguard Worker  *          text2, -1, text1, -1,
184*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_RTL, UBIDI_LOGICAL,
185*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_LTR, UBIDI_VISUAL,
186*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_MIRRORING_OFF,
187*0e209d39SAndroid Build Coastguard Worker  *          U_SHAPE_DIGITS_EN2AN | U_SHAPE_DIGIT_TYPE_AN_EXTENDED,
188*0e209d39SAndroid Build Coastguard Worker  *          &errorCode);
189*0e209d39SAndroid Build Coastguard Worker  *\endcode
190*0e209d39SAndroid Build Coastguard Worker  * </pre>
191*0e209d39SAndroid Build Coastguard Worker  * </p>
192*0e209d39SAndroid Build Coastguard Worker  *
193*0e209d39SAndroid Build Coastguard Worker  * @param pBiDiTransform A pointer to a <code>UBiDiTransform</code> object
194*0e209d39SAndroid Build Coastguard Worker  *        allocated with <code>ubiditransform_open()</code> or
195*0e209d39SAndroid Build Coastguard Worker  *        <code>NULL</code>.<p>
196*0e209d39SAndroid Build Coastguard Worker  *        This object serves for one-time setup to amortize initialization
197*0e209d39SAndroid Build Coastguard Worker  *        overheads. Use of this object is not thread-safe. All other threads
198*0e209d39SAndroid Build Coastguard Worker  *        should allocate a new <code>UBiDiTransform</code> object by calling
199*0e209d39SAndroid Build Coastguard Worker  *        <code>ubiditransform_open()</code> before using it. Alternatively,
200*0e209d39SAndroid Build Coastguard Worker  *        a caller can set this parameter to <code>NULL</code>, in which case
201*0e209d39SAndroid Build Coastguard Worker  *        the object will be allocated by the engine on the fly.</p>
202*0e209d39SAndroid Build Coastguard Worker  * @param src A pointer to the text that the Bidi layout transformations will
203*0e209d39SAndroid Build Coastguard Worker  *        be performed on.
204*0e209d39SAndroid Build Coastguard Worker  *        <p><strong>Note:</strong> the text must be (at least)
205*0e209d39SAndroid Build Coastguard Worker  *        <code>srcLength</code> long.</p>
206*0e209d39SAndroid Build Coastguard Worker  * @param srcLength The length of the text, in number of UChars. If
207*0e209d39SAndroid Build Coastguard Worker  *        <code>length == -1</code> then the text must be zero-terminated.
208*0e209d39SAndroid Build Coastguard Worker  * @param dest A pointer to where the processed text is to be copied.
209*0e209d39SAndroid Build Coastguard Worker  * @param destSize The size of the <code>dest</code> buffer, in number of
210*0e209d39SAndroid Build Coastguard Worker  *        UChars. If the <code>U_SHAPE_LETTERS_UNSHAPE</code> option is set,
211*0e209d39SAndroid Build Coastguard Worker  *        then the destination length could be as large as
212*0e209d39SAndroid Build Coastguard Worker  *        <code>srcLength * 2</code>. Otherwise, the destination length will
213*0e209d39SAndroid Build Coastguard Worker  *        not exceed <code>srcLength</code>. If the caller reserves the last
214*0e209d39SAndroid Build Coastguard Worker  *        position for zero-termination, it should be excluded from
215*0e209d39SAndroid Build Coastguard Worker  *        <code>destSize</code>.
216*0e209d39SAndroid Build Coastguard Worker  *        <p><code>destSize == -1</code> is allowed and makes sense when
217*0e209d39SAndroid Build Coastguard Worker  *        <code>dest</code> was holds some meaningful value, e.g. that of
218*0e209d39SAndroid Build Coastguard Worker  *        <code>src</code>. In this case <code>dest</code> must be
219*0e209d39SAndroid Build Coastguard Worker  *        zero-terminated.</p>
220*0e209d39SAndroid Build Coastguard Worker  * @param inParaLevel A base embedding level of the input as defined in
221*0e209d39SAndroid Build Coastguard Worker  *        <code>ubidi_setPara</code> documentation for the
222*0e209d39SAndroid Build Coastguard Worker  *        <code>paraLevel</code> parameter.
223*0e209d39SAndroid Build Coastguard Worker  * @param inOrder An order of the input, which can be one of the
224*0e209d39SAndroid Build Coastguard Worker  *        <code>UBiDiOrder</code> values.
225*0e209d39SAndroid Build Coastguard Worker  * @param outParaLevel A base embedding level of the output as defined in
226*0e209d39SAndroid Build Coastguard Worker  *        <code>ubidi_setPara</code> documentation for the
227*0e209d39SAndroid Build Coastguard Worker  *        <code>paraLevel</code> parameter.
228*0e209d39SAndroid Build Coastguard Worker  * @param outOrder An order of the output, which can be one of the
229*0e209d39SAndroid Build Coastguard Worker  *        <code>UBiDiOrder</code> values.
230*0e209d39SAndroid Build Coastguard Worker  * @param doMirroring Indicates whether or not to perform character mirroring,
231*0e209d39SAndroid Build Coastguard Worker  *        and can accept one of the <code>UBiDiMirroring</code> values.
232*0e209d39SAndroid Build Coastguard Worker  * @param shapingOptions Arabic digit and letter shaping options defined in the
233*0e209d39SAndroid Build Coastguard Worker  *        ushape.h documentation.
234*0e209d39SAndroid Build Coastguard Worker  *        <p><strong>Note:</strong> Direction indicator options are computed by
235*0e209d39SAndroid Build Coastguard Worker  *        the transformation engine based on the effective ordering schemes, so
236*0e209d39SAndroid Build Coastguard Worker  *        user-defined direction indicators will be ignored.</p>
237*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode A pointer to an error code value.
238*0e209d39SAndroid Build Coastguard Worker  *
239*0e209d39SAndroid Build Coastguard Worker  * @return The destination length, i.e. the number of UChars written to
240*0e209d39SAndroid Build Coastguard Worker  *         <code>dest</code>. If the transformation fails, the return value
241*0e209d39SAndroid Build Coastguard Worker  *         will be 0 (and the error code will be written to
242*0e209d39SAndroid Build Coastguard Worker  *         <code>pErrorCode</code>).
243*0e209d39SAndroid Build Coastguard Worker  *
244*0e209d39SAndroid Build Coastguard Worker  * @see UBiDiLevel
245*0e209d39SAndroid Build Coastguard Worker  * @see UBiDiOrder
246*0e209d39SAndroid Build Coastguard Worker  * @see UBiDiMirroring
247*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setPara
248*0e209d39SAndroid Build Coastguard Worker  * @see u_shapeArabic
249*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 58
250*0e209d39SAndroid Build Coastguard Worker  */
251*0e209d39SAndroid Build Coastguard Worker U_CAPI uint32_t U_EXPORT2
252*0e209d39SAndroid Build Coastguard Worker ubiditransform_transform(UBiDiTransform *pBiDiTransform,
253*0e209d39SAndroid Build Coastguard Worker             const UChar *src, int32_t srcLength,
254*0e209d39SAndroid Build Coastguard Worker             UChar *dest, int32_t destSize,
255*0e209d39SAndroid Build Coastguard Worker             UBiDiLevel inParaLevel, UBiDiOrder inOrder,
256*0e209d39SAndroid Build Coastguard Worker             UBiDiLevel outParaLevel, UBiDiOrder outOrder,
257*0e209d39SAndroid Build Coastguard Worker             UBiDiMirroring doMirroring, uint32_t shapingOptions,
258*0e209d39SAndroid Build Coastguard Worker             UErrorCode *pErrorCode);
259*0e209d39SAndroid Build Coastguard Worker 
260*0e209d39SAndroid Build Coastguard Worker /**
261*0e209d39SAndroid Build Coastguard Worker  * Allocates a <code>UBiDiTransform</code> object. This object can be reused,
262*0e209d39SAndroid Build Coastguard Worker  * e.g. with different ordering schemes, mirroring or shaping options.<p>
263*0e209d39SAndroid Build Coastguard Worker  * <strong>Note:</strong>The object can only be reused in the same thread.
264*0e209d39SAndroid Build Coastguard Worker  * All other threads should allocate a new <code>UBiDiTransform</code> object
265*0e209d39SAndroid Build Coastguard Worker  * before using it.<p>
266*0e209d39SAndroid Build Coastguard Worker  * Example of usage:<p>
267*0e209d39SAndroid Build Coastguard Worker  * <pre>
268*0e209d39SAndroid Build Coastguard Worker  * \code
269*0e209d39SAndroid Build Coastguard Worker  * UErrorCode errorCode = U_ZERO_ERROR;
270*0e209d39SAndroid Build Coastguard Worker  * // Open a new UBiDiTransform.
271*0e209d39SAndroid Build Coastguard Worker  * UBiDiTransform* transform = ubiditransform_open(&errorCode);
272*0e209d39SAndroid Build Coastguard Worker  * // Run a transformation.
273*0e209d39SAndroid Build Coastguard Worker  * ubiditransform_transform(transform,
274*0e209d39SAndroid Build Coastguard Worker  *          text1, -1, text2, -1,
275*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_RTL, UBIDI_LOGICAL,
276*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_LTR, UBIDI_VISUAL,
277*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_MIRRORING_ON,
278*0e209d39SAndroid Build Coastguard Worker  *          U_SHAPE_DIGITS_EN2AN,
279*0e209d39SAndroid Build Coastguard Worker  *          &errorCode);
280*0e209d39SAndroid Build Coastguard Worker  * // Do something with the output text and invoke another transformation using
281*0e209d39SAndroid Build Coastguard Worker  * //   that text as input.
282*0e209d39SAndroid Build Coastguard Worker  * ubiditransform_transform(transform,
283*0e209d39SAndroid Build Coastguard Worker  *          text2, -1, text3, -1,
284*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_LTR, UBIDI_VISUAL,
285*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_RTL, UBIDI_VISUAL,
286*0e209d39SAndroid Build Coastguard Worker  *          UBIDI_MIRRORING_ON,
287*0e209d39SAndroid Build Coastguard Worker  *          0, &errorCode);
288*0e209d39SAndroid Build Coastguard Worker  *\endcode
289*0e209d39SAndroid Build Coastguard Worker  * </pre>
290*0e209d39SAndroid Build Coastguard Worker  * <p>
291*0e209d39SAndroid Build Coastguard Worker  * The <code>UBiDiTransform</code> object must be deallocated by calling
292*0e209d39SAndroid Build Coastguard Worker  * <code>ubiditransform_close()</code>.
293*0e209d39SAndroid Build Coastguard Worker  *
294*0e209d39SAndroid Build Coastguard Worker  * @return An empty <code>UBiDiTransform</code> object.
295*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 58
296*0e209d39SAndroid Build Coastguard Worker  */
297*0e209d39SAndroid Build Coastguard Worker U_CAPI UBiDiTransform* U_EXPORT2
298*0e209d39SAndroid Build Coastguard Worker ubiditransform_open(UErrorCode *pErrorCode);
299*0e209d39SAndroid Build Coastguard Worker 
300*0e209d39SAndroid Build Coastguard Worker /**
301*0e209d39SAndroid Build Coastguard Worker  * Deallocates the given <code>UBiDiTransform</code> object.
302*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 58
303*0e209d39SAndroid Build Coastguard Worker  */
304*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
305*0e209d39SAndroid Build Coastguard Worker ubiditransform_close(UBiDiTransform *pBidiTransform);
306*0e209d39SAndroid Build Coastguard Worker 
307*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
308*0e209d39SAndroid Build Coastguard Worker 
309*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
310*0e209d39SAndroid Build Coastguard Worker 
311*0e209d39SAndroid Build Coastguard Worker /**
312*0e209d39SAndroid Build Coastguard Worker  * \class LocalUBiDiTransformPointer
313*0e209d39SAndroid Build Coastguard Worker  * "Smart pointer" class, closes a UBiDiTransform via ubiditransform_close().
314*0e209d39SAndroid Build Coastguard Worker  * For most methods see the LocalPointerBase base class.
315*0e209d39SAndroid Build Coastguard Worker  *
316*0e209d39SAndroid Build Coastguard Worker  * @see LocalPointerBase
317*0e209d39SAndroid Build Coastguard Worker  * @see LocalPointer
318*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 58
319*0e209d39SAndroid Build Coastguard Worker  */
320*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUBiDiTransformPointer, UBiDiTransform, ubiditransform_close);
321*0e209d39SAndroid Build Coastguard Worker 
322*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
323*0e209d39SAndroid Build Coastguard Worker 
324*0e209d39SAndroid Build Coastguard Worker #endif
325*0e209d39SAndroid Build Coastguard Worker 
326*0e209d39SAndroid Build Coastguard Worker #endif
327