xref: /aosp_15_r20/external/icu/libicu/ndk_headers/unicode/ubidi.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker /*
4*0e209d39SAndroid Build Coastguard Worker ******************************************************************************
5*0e209d39SAndroid Build Coastguard Worker *
6*0e209d39SAndroid Build Coastguard Worker *   Copyright (C) 1999-2013, International Business Machines
7*0e209d39SAndroid Build Coastguard Worker *   Corporation and others.  All Rights Reserved.
8*0e209d39SAndroid Build Coastguard Worker *
9*0e209d39SAndroid Build Coastguard Worker ******************************************************************************
10*0e209d39SAndroid Build Coastguard Worker *   file name:  ubidi.h
11*0e209d39SAndroid Build Coastguard Worker *   encoding:   UTF-8
12*0e209d39SAndroid Build Coastguard Worker *   tab size:   8 (not used)
13*0e209d39SAndroid Build Coastguard Worker *   indentation:4
14*0e209d39SAndroid Build Coastguard Worker *
15*0e209d39SAndroid Build Coastguard Worker *   created on: 1999jul27
16*0e209d39SAndroid Build Coastguard Worker *   created by: Markus W. Scherer, updated by Matitiahu Allouche
17*0e209d39SAndroid Build Coastguard Worker */
18*0e209d39SAndroid Build Coastguard Worker 
19*0e209d39SAndroid Build Coastguard Worker #ifndef UBIDI_H
20*0e209d39SAndroid Build Coastguard Worker #define UBIDI_H
21*0e209d39SAndroid Build Coastguard Worker 
22*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.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 algorithm
32*0e209d39SAndroid Build Coastguard Worker  *
33*0e209d39SAndroid Build Coastguard Worker  * <h2>Bidi algorithm for ICU</h2>
34*0e209d39SAndroid Build Coastguard Worker  *
35*0e209d39SAndroid Build Coastguard Worker  * This is an implementation of the Unicode Bidirectional Algorithm.
36*0e209d39SAndroid Build Coastguard Worker  * The algorithm is defined in the
37*0e209d39SAndroid Build Coastguard Worker  * <a href="http://www.unicode.org/unicode/reports/tr9/">Unicode Standard Annex #9</a>.<p>
38*0e209d39SAndroid Build Coastguard Worker  *
39*0e209d39SAndroid Build Coastguard Worker  * Note: Libraries that perform a bidirectional algorithm and
40*0e209d39SAndroid Build Coastguard Worker  * reorder strings accordingly are sometimes called "Storage Layout Engines".
41*0e209d39SAndroid Build Coastguard Worker  * ICU's Bidi and shaping (u_shapeArabic()) APIs can be used at the core of such
42*0e209d39SAndroid Build Coastguard Worker  * "Storage Layout Engines".
43*0e209d39SAndroid Build Coastguard Worker  *
44*0e209d39SAndroid Build Coastguard Worker  * <h3>General remarks about the API:</h3>
45*0e209d39SAndroid Build Coastguard Worker  *
46*0e209d39SAndroid Build Coastguard Worker  * In functions with an error code parameter,
47*0e209d39SAndroid Build Coastguard Worker  * the <code>pErrorCode</code> pointer must be valid
48*0e209d39SAndroid Build Coastguard Worker  * and the value that it points to must not indicate a failure before
49*0e209d39SAndroid Build Coastguard Worker  * the function call. Otherwise, the function returns immediately.
50*0e209d39SAndroid Build Coastguard Worker  * After the function call, the value indicates success or failure.<p>
51*0e209d39SAndroid Build Coastguard Worker  *
52*0e209d39SAndroid Build Coastguard Worker  * The &quot;limit&quot; of a sequence of characters is the position just after their
53*0e209d39SAndroid Build Coastguard Worker  * last character, i.e., one more than that position.<p>
54*0e209d39SAndroid Build Coastguard Worker  *
55*0e209d39SAndroid Build Coastguard Worker  * Some of the API functions provide access to &quot;runs&quot;.
56*0e209d39SAndroid Build Coastguard Worker  * Such a &quot;run&quot; is defined as a sequence of characters
57*0e209d39SAndroid Build Coastguard Worker  * that are at the same embedding level
58*0e209d39SAndroid Build Coastguard Worker  * after performing the Bidi algorithm.<p>
59*0e209d39SAndroid Build Coastguard Worker  *
60*0e209d39SAndroid Build Coastguard Worker  * @author Markus W. Scherer
61*0e209d39SAndroid Build Coastguard Worker  * @version 1.0
62*0e209d39SAndroid Build Coastguard Worker  *
63*0e209d39SAndroid Build Coastguard Worker  *
64*0e209d39SAndroid Build Coastguard Worker  * <h4> Sample code for the ICU Bidi API </h4>
65*0e209d39SAndroid Build Coastguard Worker  *
66*0e209d39SAndroid Build Coastguard Worker  * <h5>Rendering a paragraph with the ICU Bidi API</h5>
67*0e209d39SAndroid Build Coastguard Worker  *
68*0e209d39SAndroid Build Coastguard Worker  * This is (hypothetical) sample code that illustrates
69*0e209d39SAndroid Build Coastguard Worker  * how the ICU Bidi API could be used to render a paragraph of text.
70*0e209d39SAndroid Build Coastguard Worker  * Rendering code depends highly on the graphics system,
71*0e209d39SAndroid Build Coastguard Worker  * therefore this sample code must make a lot of assumptions,
72*0e209d39SAndroid Build Coastguard Worker  * which may or may not match any existing graphics system's properties.
73*0e209d39SAndroid Build Coastguard Worker  *
74*0e209d39SAndroid Build Coastguard Worker  * <p>The basic assumptions are:</p>
75*0e209d39SAndroid Build Coastguard Worker  * <ul>
76*0e209d39SAndroid Build Coastguard Worker  * <li>Rendering is done from left to right on a horizontal line.</li>
77*0e209d39SAndroid Build Coastguard Worker  * <li>A run of single-style, unidirectional text can be rendered at once.</li>
78*0e209d39SAndroid Build Coastguard Worker  * <li>Such a run of text is passed to the graphics system with
79*0e209d39SAndroid Build Coastguard Worker  *     characters (code units) in logical order.</li>
80*0e209d39SAndroid Build Coastguard Worker  * <li>The line-breaking algorithm is very complicated
81*0e209d39SAndroid Build Coastguard Worker  *     and Locale-dependent -
82*0e209d39SAndroid Build Coastguard Worker  *     and therefore its implementation omitted from this sample code.</li>
83*0e209d39SAndroid Build Coastguard Worker  * </ul>
84*0e209d39SAndroid Build Coastguard Worker  *
85*0e209d39SAndroid Build Coastguard Worker  * <pre>
86*0e209d39SAndroid Build Coastguard Worker  * \code
87*0e209d39SAndroid Build Coastguard Worker  *#include <unicode/ubidi.h>
88*0e209d39SAndroid Build Coastguard Worker  *
89*0e209d39SAndroid Build Coastguard Worker  *typedef enum {
90*0e209d39SAndroid Build Coastguard Worker  *     styleNormal=0, styleSelected=1,
91*0e209d39SAndroid Build Coastguard Worker  *     styleBold=2, styleItalics=4,
92*0e209d39SAndroid Build Coastguard Worker  *     styleSuper=8, styleSub=16
93*0e209d39SAndroid Build Coastguard Worker  *} Style;
94*0e209d39SAndroid Build Coastguard Worker  *
95*0e209d39SAndroid Build Coastguard Worker  *typedef struct { int32_t limit; Style style; } StyleRun;
96*0e209d39SAndroid Build Coastguard Worker  *
97*0e209d39SAndroid Build Coastguard Worker  *int getTextWidth(const UChar *text, int32_t start, int32_t limit,
98*0e209d39SAndroid Build Coastguard Worker  *                  const StyleRun *styleRuns, int styleRunCount);
99*0e209d39SAndroid Build Coastguard Worker  *
100*0e209d39SAndroid Build Coastguard Worker  * // set *pLimit and *pStyleRunLimit for a line
101*0e209d39SAndroid Build Coastguard Worker  * // from text[start] and from styleRuns[styleRunStart]
102*0e209d39SAndroid Build Coastguard Worker  * // using ubidi_getLogicalRun(para, ...)
103*0e209d39SAndroid Build Coastguard Worker  *void getLineBreak(const UChar *text, int32_t start, int32_t *pLimit,
104*0e209d39SAndroid Build Coastguard Worker  *                  UBiDi *para,
105*0e209d39SAndroid Build Coastguard Worker  *                  const StyleRun *styleRuns, int styleRunStart, int *pStyleRunLimit,
106*0e209d39SAndroid Build Coastguard Worker  *                  int *pLineWidth);
107*0e209d39SAndroid Build Coastguard Worker  *
108*0e209d39SAndroid Build Coastguard Worker  * // render runs on a line sequentially, always from left to right
109*0e209d39SAndroid Build Coastguard Worker  *
110*0e209d39SAndroid Build Coastguard Worker  * // prepare rendering a new line
111*0e209d39SAndroid Build Coastguard Worker  * void startLine(UBiDiDirection textDirection, int lineWidth);
112*0e209d39SAndroid Build Coastguard Worker  *
113*0e209d39SAndroid Build Coastguard Worker  * // render a run of text and advance to the right by the run width
114*0e209d39SAndroid Build Coastguard Worker  * // the text[start..limit-1] is always in logical order
115*0e209d39SAndroid Build Coastguard Worker  * void renderRun(const UChar *text, int32_t start, int32_t limit,
116*0e209d39SAndroid Build Coastguard Worker  *               UBiDiDirection textDirection, Style style);
117*0e209d39SAndroid Build Coastguard Worker  *
118*0e209d39SAndroid Build Coastguard Worker  * // We could compute a cross-product
119*0e209d39SAndroid Build Coastguard Worker  * // from the style runs with the directional runs
120*0e209d39SAndroid Build Coastguard Worker  * // and then reorder it.
121*0e209d39SAndroid Build Coastguard Worker  * // Instead, here we iterate over each run type
122*0e209d39SAndroid Build Coastguard Worker  * // and render the intersections -
123*0e209d39SAndroid Build Coastguard Worker  * // with shortcuts in simple (and common) cases.
124*0e209d39SAndroid Build Coastguard Worker  * // renderParagraph() is the main function.
125*0e209d39SAndroid Build Coastguard Worker  *
126*0e209d39SAndroid Build Coastguard Worker  * // render a directional run with
127*0e209d39SAndroid Build Coastguard Worker  * // (possibly) multiple style runs intersecting with it
128*0e209d39SAndroid Build Coastguard Worker  * void renderDirectionalRun(const UChar *text,
129*0e209d39SAndroid Build Coastguard Worker  *                           int32_t start, int32_t limit,
130*0e209d39SAndroid Build Coastguard Worker  *                           UBiDiDirection direction,
131*0e209d39SAndroid Build Coastguard Worker  *                           const StyleRun *styleRuns, int styleRunCount) {
132*0e209d39SAndroid Build Coastguard Worker  *     int i;
133*0e209d39SAndroid Build Coastguard Worker  *
134*0e209d39SAndroid Build Coastguard Worker  *     // iterate over style runs
135*0e209d39SAndroid Build Coastguard Worker  *     if(direction==UBIDI_LTR) {
136*0e209d39SAndroid Build Coastguard Worker  *         int styleLimit;
137*0e209d39SAndroid Build Coastguard Worker  *
138*0e209d39SAndroid Build Coastguard Worker  *         for(i=0; i<styleRunCount; ++i) {
139*0e209d39SAndroid Build Coastguard Worker  *             styleLimit=styleRuns[i].limit;
140*0e209d39SAndroid Build Coastguard Worker  *             if(start<styleLimit) {
141*0e209d39SAndroid Build Coastguard Worker  *                 if(styleLimit>limit) { styleLimit=limit; }
142*0e209d39SAndroid Build Coastguard Worker  *                 renderRun(text, start, styleLimit,
143*0e209d39SAndroid Build Coastguard Worker  *                           direction, styleRuns[i].style);
144*0e209d39SAndroid Build Coastguard Worker  *                 if(styleLimit==limit) { break; }
145*0e209d39SAndroid Build Coastguard Worker  *                 start=styleLimit;
146*0e209d39SAndroid Build Coastguard Worker  *             }
147*0e209d39SAndroid Build Coastguard Worker  *         }
148*0e209d39SAndroid Build Coastguard Worker  *     } else {
149*0e209d39SAndroid Build Coastguard Worker  *         int styleStart;
150*0e209d39SAndroid Build Coastguard Worker  *
151*0e209d39SAndroid Build Coastguard Worker  *         for(i=styleRunCount-1; i>=0; --i) {
152*0e209d39SAndroid Build Coastguard Worker  *             if(i>0) {
153*0e209d39SAndroid Build Coastguard Worker  *                 styleStart=styleRuns[i-1].limit;
154*0e209d39SAndroid Build Coastguard Worker  *             } else {
155*0e209d39SAndroid Build Coastguard Worker  *                 styleStart=0;
156*0e209d39SAndroid Build Coastguard Worker  *             }
157*0e209d39SAndroid Build Coastguard Worker  *             if(limit>=styleStart) {
158*0e209d39SAndroid Build Coastguard Worker  *                 if(styleStart<start) { styleStart=start; }
159*0e209d39SAndroid Build Coastguard Worker  *                 renderRun(text, styleStart, limit,
160*0e209d39SAndroid Build Coastguard Worker  *                           direction, styleRuns[i].style);
161*0e209d39SAndroid Build Coastguard Worker  *                 if(styleStart==start) { break; }
162*0e209d39SAndroid Build Coastguard Worker  *                 limit=styleStart;
163*0e209d39SAndroid Build Coastguard Worker  *             }
164*0e209d39SAndroid Build Coastguard Worker  *         }
165*0e209d39SAndroid Build Coastguard Worker  *     }
166*0e209d39SAndroid Build Coastguard Worker  * }
167*0e209d39SAndroid Build Coastguard Worker  *
168*0e209d39SAndroid Build Coastguard Worker  * // the line object represents text[start..limit-1]
169*0e209d39SAndroid Build Coastguard Worker  * void renderLine(UBiDi *line, const UChar *text,
170*0e209d39SAndroid Build Coastguard Worker  *                 int32_t start, int32_t limit,
171*0e209d39SAndroid Build Coastguard Worker  *                 const StyleRun *styleRuns, int styleRunCount,
172*0e209d39SAndroid Build Coastguard Worker  *                 UErrorCode *pErrorCode) {
173*0e209d39SAndroid Build Coastguard Worker  *     UBiDiDirection direction=ubidi_getDirection(line);
174*0e209d39SAndroid Build Coastguard Worker  *     if(direction!=UBIDI_MIXED) {
175*0e209d39SAndroid Build Coastguard Worker  *         // unidirectional
176*0e209d39SAndroid Build Coastguard Worker  *         if(styleRunCount<=1) {
177*0e209d39SAndroid Build Coastguard Worker  *             renderRun(text, start, limit, direction, styleRuns[0].style);
178*0e209d39SAndroid Build Coastguard Worker  *         } else {
179*0e209d39SAndroid Build Coastguard Worker  *             renderDirectionalRun(text, start, limit,
180*0e209d39SAndroid Build Coastguard Worker  *                                  direction, styleRuns, styleRunCount);
181*0e209d39SAndroid Build Coastguard Worker  *         }
182*0e209d39SAndroid Build Coastguard Worker  *     } else {
183*0e209d39SAndroid Build Coastguard Worker  *         // mixed-directional
184*0e209d39SAndroid Build Coastguard Worker  *         int32_t count, i, length;
185*0e209d39SAndroid Build Coastguard Worker  *         UBiDiLevel level;
186*0e209d39SAndroid Build Coastguard Worker  *
187*0e209d39SAndroid Build Coastguard Worker  *         count=ubidi_countRuns(line, pErrorCode);
188*0e209d39SAndroid Build Coastguard Worker  *         if(U_SUCCESS(*pErrorCode)) {
189*0e209d39SAndroid Build Coastguard Worker  *             if(styleRunCount<=1) {
190*0e209d39SAndroid Build Coastguard Worker  *                 Style style=styleRuns[0].style;
191*0e209d39SAndroid Build Coastguard Worker  *
192*0e209d39SAndroid Build Coastguard Worker  *                 // iterate over directional runs
193*0e209d39SAndroid Build Coastguard Worker  *                for(i=0; i<count; ++i) {
194*0e209d39SAndroid Build Coastguard Worker  *                    direction=ubidi_getVisualRun(line, i, &start, &length);
195*0e209d39SAndroid Build Coastguard Worker  *                     renderRun(text, start, start+length, direction, style);
196*0e209d39SAndroid Build Coastguard Worker  *                }
197*0e209d39SAndroid Build Coastguard Worker  *             } else {
198*0e209d39SAndroid Build Coastguard Worker  *                 int32_t j;
199*0e209d39SAndroid Build Coastguard Worker  *
200*0e209d39SAndroid Build Coastguard Worker  *                 // iterate over both directional and style runs
201*0e209d39SAndroid Build Coastguard Worker  *                 for(i=0; i<count; ++i) {
202*0e209d39SAndroid Build Coastguard Worker  *                     direction=ubidi_getVisualRun(line, i, &start, &length);
203*0e209d39SAndroid Build Coastguard Worker  *                     renderDirectionalRun(text, start, start+length,
204*0e209d39SAndroid Build Coastguard Worker  *                                          direction, styleRuns, styleRunCount);
205*0e209d39SAndroid Build Coastguard Worker  *                 }
206*0e209d39SAndroid Build Coastguard Worker  *             }
207*0e209d39SAndroid Build Coastguard Worker  *         }
208*0e209d39SAndroid Build Coastguard Worker  *     }
209*0e209d39SAndroid Build Coastguard Worker  * }
210*0e209d39SAndroid Build Coastguard Worker  *
211*0e209d39SAndroid Build Coastguard Worker  *void renderParagraph(const UChar *text, int32_t length,
212*0e209d39SAndroid Build Coastguard Worker  *                     UBiDiDirection textDirection,
213*0e209d39SAndroid Build Coastguard Worker  *                      const StyleRun *styleRuns, int styleRunCount,
214*0e209d39SAndroid Build Coastguard Worker  *                      int lineWidth,
215*0e209d39SAndroid Build Coastguard Worker  *                      UErrorCode *pErrorCode) {
216*0e209d39SAndroid Build Coastguard Worker  *     UBiDi *para;
217*0e209d39SAndroid Build Coastguard Worker  *
218*0e209d39SAndroid Build Coastguard Worker  *     if(pErrorCode==NULL || U_FAILURE(*pErrorCode) || length<=0) {
219*0e209d39SAndroid Build Coastguard Worker  *         return;
220*0e209d39SAndroid Build Coastguard Worker  *     }
221*0e209d39SAndroid Build Coastguard Worker  *
222*0e209d39SAndroid Build Coastguard Worker  *     para=ubidi_openSized(length, 0, pErrorCode);
223*0e209d39SAndroid Build Coastguard Worker  *     if(para==NULL) { return; }
224*0e209d39SAndroid Build Coastguard Worker  *
225*0e209d39SAndroid Build Coastguard Worker  *     ubidi_setPara(para, text, length,
226*0e209d39SAndroid Build Coastguard Worker  *                   textDirection ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR,
227*0e209d39SAndroid Build Coastguard Worker  *                   NULL, pErrorCode);
228*0e209d39SAndroid Build Coastguard Worker  *     if(U_SUCCESS(*pErrorCode)) {
229*0e209d39SAndroid Build Coastguard Worker  *         UBiDiLevel paraLevel=1&ubidi_getParaLevel(para);
230*0e209d39SAndroid Build Coastguard Worker  *         StyleRun styleRun={ length, styleNormal };
231*0e209d39SAndroid Build Coastguard Worker  *         int width;
232*0e209d39SAndroid Build Coastguard Worker  *
233*0e209d39SAndroid Build Coastguard Worker  *         if(styleRuns==NULL || styleRunCount<=0) {
234*0e209d39SAndroid Build Coastguard Worker  *            styleRunCount=1;
235*0e209d39SAndroid Build Coastguard Worker  *             styleRuns=&styleRun;
236*0e209d39SAndroid Build Coastguard Worker  *         }
237*0e209d39SAndroid Build Coastguard Worker  *
238*0e209d39SAndroid Build Coastguard Worker  *        // assume styleRuns[styleRunCount-1].limit>=length
239*0e209d39SAndroid Build Coastguard Worker  *
240*0e209d39SAndroid Build Coastguard Worker  *         width=getTextWidth(text, 0, length, styleRuns, styleRunCount);
241*0e209d39SAndroid Build Coastguard Worker  *         if(width<=lineWidth) {
242*0e209d39SAndroid Build Coastguard Worker  *             // everything fits onto one line
243*0e209d39SAndroid Build Coastguard Worker  *
244*0e209d39SAndroid Build Coastguard Worker  *            // prepare rendering a new line from either left or right
245*0e209d39SAndroid Build Coastguard Worker  *             startLine(paraLevel, width);
246*0e209d39SAndroid Build Coastguard Worker  *
247*0e209d39SAndroid Build Coastguard Worker  *             renderLine(para, text, 0, length,
248*0e209d39SAndroid Build Coastguard Worker  *                        styleRuns, styleRunCount, pErrorCode);
249*0e209d39SAndroid Build Coastguard Worker  *         } else {
250*0e209d39SAndroid Build Coastguard Worker  *             UBiDi *line;
251*0e209d39SAndroid Build Coastguard Worker  *
252*0e209d39SAndroid Build Coastguard Worker  *             // we need to render several lines
253*0e209d39SAndroid Build Coastguard Worker  *             line=ubidi_openSized(length, 0, pErrorCode);
254*0e209d39SAndroid Build Coastguard Worker  *             if(line!=NULL) {
255*0e209d39SAndroid Build Coastguard Worker  *                 int32_t start=0, limit;
256*0e209d39SAndroid Build Coastguard Worker  *                 int styleRunStart=0, styleRunLimit;
257*0e209d39SAndroid Build Coastguard Worker  *
258*0e209d39SAndroid Build Coastguard Worker  *                 for(;;) {
259*0e209d39SAndroid Build Coastguard Worker  *                     limit=length;
260*0e209d39SAndroid Build Coastguard Worker  *                     styleRunLimit=styleRunCount;
261*0e209d39SAndroid Build Coastguard Worker  *                     getLineBreak(text, start, &limit, para,
262*0e209d39SAndroid Build Coastguard Worker  *                                  styleRuns, styleRunStart, &styleRunLimit,
263*0e209d39SAndroid Build Coastguard Worker  *                                 &width);
264*0e209d39SAndroid Build Coastguard Worker  *                     ubidi_setLine(para, start, limit, line, pErrorCode);
265*0e209d39SAndroid Build Coastguard Worker  *                     if(U_SUCCESS(*pErrorCode)) {
266*0e209d39SAndroid Build Coastguard Worker  *                         // prepare rendering a new line
267*0e209d39SAndroid Build Coastguard Worker  *                         // from either left or right
268*0e209d39SAndroid Build Coastguard Worker  *                         startLine(paraLevel, width);
269*0e209d39SAndroid Build Coastguard Worker  *
270*0e209d39SAndroid Build Coastguard Worker  *                         renderLine(line, text, start, limit,
271*0e209d39SAndroid Build Coastguard Worker  *                                    styleRuns+styleRunStart,
272*0e209d39SAndroid Build Coastguard Worker  *                                    styleRunLimit-styleRunStart, pErrorCode);
273*0e209d39SAndroid Build Coastguard Worker  *                     }
274*0e209d39SAndroid Build Coastguard Worker  *                     if(limit==length) { break; }
275*0e209d39SAndroid Build Coastguard Worker  *                     start=limit;
276*0e209d39SAndroid Build Coastguard Worker  *                     styleRunStart=styleRunLimit-1;
277*0e209d39SAndroid Build Coastguard Worker  *                     if(start>=styleRuns[styleRunStart].limit) {
278*0e209d39SAndroid Build Coastguard Worker  *                         ++styleRunStart;
279*0e209d39SAndroid Build Coastguard Worker  *                     }
280*0e209d39SAndroid Build Coastguard Worker  *                 }
281*0e209d39SAndroid Build Coastguard Worker  *
282*0e209d39SAndroid Build Coastguard Worker  *                 ubidi_close(line);
283*0e209d39SAndroid Build Coastguard Worker  *             }
284*0e209d39SAndroid Build Coastguard Worker  *        }
285*0e209d39SAndroid Build Coastguard Worker  *    }
286*0e209d39SAndroid Build Coastguard Worker  *
287*0e209d39SAndroid Build Coastguard Worker  *     ubidi_close(para);
288*0e209d39SAndroid Build Coastguard Worker  *}
289*0e209d39SAndroid Build Coastguard Worker  *\endcode
290*0e209d39SAndroid Build Coastguard Worker  * </pre>
291*0e209d39SAndroid Build Coastguard Worker  */
292*0e209d39SAndroid Build Coastguard Worker 
293*0e209d39SAndroid Build Coastguard Worker /*DOCXX_TAG*/
294*0e209d39SAndroid Build Coastguard Worker /*@addtogroup icu4c ICU4C*/
295*0e209d39SAndroid Build Coastguard Worker /*@{*/
296*0e209d39SAndroid Build Coastguard Worker 
297*0e209d39SAndroid Build Coastguard Worker /**
298*0e209d39SAndroid Build Coastguard Worker  * UBiDiLevel is the type of the level values in this
299*0e209d39SAndroid Build Coastguard Worker  * Bidi implementation.
300*0e209d39SAndroid Build Coastguard Worker  * It holds an embedding level and indicates the visual direction
301*0e209d39SAndroid Build Coastguard Worker  * by its bit&nbsp;0 (even/odd value).<p>
302*0e209d39SAndroid Build Coastguard Worker  *
303*0e209d39SAndroid Build Coastguard Worker  * It can also hold non-level values for the
304*0e209d39SAndroid Build Coastguard Worker  * <code>paraLevel</code> and <code>embeddingLevels</code>
305*0e209d39SAndroid Build Coastguard Worker  * arguments of <code>ubidi_setPara()</code>; there:
306*0e209d39SAndroid Build Coastguard Worker  * <ul>
307*0e209d39SAndroid Build Coastguard Worker  * <li>bit&nbsp;7 of an <code>embeddingLevels[]</code>
308*0e209d39SAndroid Build Coastguard Worker  * value indicates whether the using application is
309*0e209d39SAndroid Build Coastguard Worker  * specifying the level of a character to <i>override</i> whatever the
310*0e209d39SAndroid Build Coastguard Worker  * Bidi implementation would resolve it to.</li>
311*0e209d39SAndroid Build Coastguard Worker  * <li><code>paraLevel</code> can be set to the
312*0e209d39SAndroid Build Coastguard Worker  * pseudo-level values <code>UBIDI_DEFAULT_LTR</code>
313*0e209d39SAndroid Build Coastguard Worker  * and <code>UBIDI_DEFAULT_RTL</code>.</li>
314*0e209d39SAndroid Build Coastguard Worker  * </ul>
315*0e209d39SAndroid Build Coastguard Worker  *
316*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setPara
317*0e209d39SAndroid Build Coastguard Worker  *
318*0e209d39SAndroid Build Coastguard Worker  * <p>The related constants are not real, valid level values.
319*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_DEFAULT_XXX</code> can be used to specify
320*0e209d39SAndroid Build Coastguard Worker  * a default for the paragraph level for
321*0e209d39SAndroid Build Coastguard Worker  * when the <code>ubidi_setPara()</code> function
322*0e209d39SAndroid Build Coastguard Worker  * shall determine it but there is no
323*0e209d39SAndroid Build Coastguard Worker  * strongly typed character in the input.<p>
324*0e209d39SAndroid Build Coastguard Worker  *
325*0e209d39SAndroid Build Coastguard Worker  * Note that the value for <code>UBIDI_DEFAULT_LTR</code> is even
326*0e209d39SAndroid Build Coastguard Worker  * and the one for <code>UBIDI_DEFAULT_RTL</code> is odd,
327*0e209d39SAndroid Build Coastguard Worker  * just like with normal LTR and RTL level values -
328*0e209d39SAndroid Build Coastguard Worker  * these special values are designed that way. Also, the implementation
329*0e209d39SAndroid Build Coastguard Worker  * assumes that UBIDI_MAX_EXPLICIT_LEVEL is odd.
330*0e209d39SAndroid Build Coastguard Worker  *
331*0e209d39SAndroid Build Coastguard Worker  * Note: The numeric values of the related constants will not change:
332*0e209d39SAndroid Build Coastguard Worker  * They are tied to the use of 7-bit byte values (plus the override bit)
333*0e209d39SAndroid Build Coastguard Worker  * and of the UBiDiLevel=uint8_t data type in this API.
334*0e209d39SAndroid Build Coastguard Worker  *
335*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_DEFAULT_LTR
336*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_DEFAULT_RTL
337*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_LEVEL_OVERRIDE
338*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_MAX_EXPLICIT_LEVEL
339*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
340*0e209d39SAndroid Build Coastguard Worker  */
341*0e209d39SAndroid Build Coastguard Worker typedef uint8_t UBiDiLevel;
342*0e209d39SAndroid Build Coastguard Worker 
343*0e209d39SAndroid Build Coastguard Worker /** Paragraph level setting.<p>
344*0e209d39SAndroid Build Coastguard Worker  *
345*0e209d39SAndroid Build Coastguard Worker  * Constant indicating that the base direction depends on the first strong
346*0e209d39SAndroid Build Coastguard Worker  * directional character in the text according to the Unicode Bidirectional
347*0e209d39SAndroid Build Coastguard Worker  * Algorithm. If no strong directional character is present,
348*0e209d39SAndroid Build Coastguard Worker  * then set the paragraph level to 0 (left-to-right).<p>
349*0e209d39SAndroid Build Coastguard Worker  *
350*0e209d39SAndroid Build Coastguard Worker  * If this value is used in conjunction with reordering modes
351*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_REORDER_INVERSE_LIKE_DIRECT</code> or
352*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code>, the text to reorder
353*0e209d39SAndroid Build Coastguard Worker  * is assumed to be visual LTR, and the text after reordering is required
354*0e209d39SAndroid Build Coastguard Worker  * to be the corresponding logical string with appropriate contextual
355*0e209d39SAndroid Build Coastguard Worker  * direction. The direction of the result string will be RTL if either
356*0e209d39SAndroid Build Coastguard Worker  * the righmost or leftmost strong character of the source text is RTL
357*0e209d39SAndroid Build Coastguard Worker  * or Arabic Letter, the direction will be LTR otherwise.<p>
358*0e209d39SAndroid Build Coastguard Worker  *
359*0e209d39SAndroid Build Coastguard Worker  * If reordering option <code>UBIDI_OPTION_INSERT_MARKS</code> is set, an RLM may
360*0e209d39SAndroid Build Coastguard Worker  * be added at the beginning of the result string to ensure round trip
361*0e209d39SAndroid Build Coastguard Worker  * (that the result string, when reordered back to visual, will produce
362*0e209d39SAndroid Build Coastguard Worker  * the original source text).
363*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_REORDER_INVERSE_LIKE_DIRECT
364*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL
365*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
366*0e209d39SAndroid Build Coastguard Worker  */
367*0e209d39SAndroid Build Coastguard Worker #define UBIDI_DEFAULT_LTR 0xfe
368*0e209d39SAndroid Build Coastguard Worker 
369*0e209d39SAndroid Build Coastguard Worker /** Paragraph level setting.<p>
370*0e209d39SAndroid Build Coastguard Worker  *
371*0e209d39SAndroid Build Coastguard Worker  * Constant indicating that the base direction depends on the first strong
372*0e209d39SAndroid Build Coastguard Worker  * directional character in the text according to the Unicode Bidirectional
373*0e209d39SAndroid Build Coastguard Worker  * Algorithm. If no strong directional character is present,
374*0e209d39SAndroid Build Coastguard Worker  * then set the paragraph level to 1 (right-to-left).<p>
375*0e209d39SAndroid Build Coastguard Worker  *
376*0e209d39SAndroid Build Coastguard Worker  * If this value is used in conjunction with reordering modes
377*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_REORDER_INVERSE_LIKE_DIRECT</code> or
378*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code>, the text to reorder
379*0e209d39SAndroid Build Coastguard Worker  * is assumed to be visual LTR, and the text after reordering is required
380*0e209d39SAndroid Build Coastguard Worker  * to be the corresponding logical string with appropriate contextual
381*0e209d39SAndroid Build Coastguard Worker  * direction. The direction of the result string will be RTL if either
382*0e209d39SAndroid Build Coastguard Worker  * the righmost or leftmost strong character of the source text is RTL
383*0e209d39SAndroid Build Coastguard Worker  * or Arabic Letter, or if the text contains no strong character;
384*0e209d39SAndroid Build Coastguard Worker  * the direction will be LTR otherwise.<p>
385*0e209d39SAndroid Build Coastguard Worker  *
386*0e209d39SAndroid Build Coastguard Worker  * If reordering option <code>UBIDI_OPTION_INSERT_MARKS</code> is set, an RLM may
387*0e209d39SAndroid Build Coastguard Worker  * be added at the beginning of the result string to ensure round trip
388*0e209d39SAndroid Build Coastguard Worker  * (that the result string, when reordered back to visual, will produce
389*0e209d39SAndroid Build Coastguard Worker  * the original source text).
390*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_REORDER_INVERSE_LIKE_DIRECT
391*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL
392*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
393*0e209d39SAndroid Build Coastguard Worker  */
394*0e209d39SAndroid Build Coastguard Worker #define UBIDI_DEFAULT_RTL 0xff
395*0e209d39SAndroid Build Coastguard Worker 
396*0e209d39SAndroid Build Coastguard Worker /**
397*0e209d39SAndroid Build Coastguard Worker  * Maximum explicit embedding level.
398*0e209d39SAndroid Build Coastguard Worker  * Same as the max_depth value in the
399*0e209d39SAndroid Build Coastguard Worker  * <a href="http://www.unicode.org/reports/tr9/#BD2">Unicode Bidirectional Algorithm</a>.
400*0e209d39SAndroid Build Coastguard Worker  * (The maximum resolved level can be up to <code>UBIDI_MAX_EXPLICIT_LEVEL+1</code>).
401*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
402*0e209d39SAndroid Build Coastguard Worker  */
403*0e209d39SAndroid Build Coastguard Worker #define UBIDI_MAX_EXPLICIT_LEVEL 125
404*0e209d39SAndroid Build Coastguard Worker 
405*0e209d39SAndroid Build Coastguard Worker /** Bit flag for level input.
406*0e209d39SAndroid Build Coastguard Worker  *  Overrides directional properties.
407*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
408*0e209d39SAndroid Build Coastguard Worker  */
409*0e209d39SAndroid Build Coastguard Worker #define UBIDI_LEVEL_OVERRIDE 0x80
410*0e209d39SAndroid Build Coastguard Worker 
411*0e209d39SAndroid Build Coastguard Worker /**
412*0e209d39SAndroid Build Coastguard Worker  * Special value which can be returned by the mapping functions when a logical
413*0e209d39SAndroid Build Coastguard Worker  * index has no corresponding visual index or vice-versa. This may happen
414*0e209d39SAndroid Build Coastguard Worker  * for the logical-to-visual mapping of a Bidi control when option
415*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> is specified. This can also happen
416*0e209d39SAndroid Build Coastguard Worker  * for the visual-to-logical mapping of a Bidi mark (LRM or RLM) inserted
417*0e209d39SAndroid Build Coastguard Worker  * by option <code>#UBIDI_OPTION_INSERT_MARKS</code>.
418*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getVisualIndex
419*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getVisualMap
420*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getLogicalIndex
421*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getLogicalMap
422*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
423*0e209d39SAndroid Build Coastguard Worker  */
424*0e209d39SAndroid Build Coastguard Worker #define UBIDI_MAP_NOWHERE   (-1)
425*0e209d39SAndroid Build Coastguard Worker 
426*0e209d39SAndroid Build Coastguard Worker /**
427*0e209d39SAndroid Build Coastguard Worker  * <code>UBiDiDirection</code> values indicate the text direction.
428*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
429*0e209d39SAndroid Build Coastguard Worker  */
430*0e209d39SAndroid Build Coastguard Worker enum UBiDiDirection {
431*0e209d39SAndroid Build Coastguard Worker   /** Left-to-right text. This is a 0 value.
432*0e209d39SAndroid Build Coastguard Worker    * <ul>
433*0e209d39SAndroid Build Coastguard Worker    * <li>As return value for <code>ubidi_getDirection()</code>, it means
434*0e209d39SAndroid Build Coastguard Worker    *     that the source string contains no right-to-left characters, or
435*0e209d39SAndroid Build Coastguard Worker    *     that the source string is empty and the paragraph level is even.
436*0e209d39SAndroid Build Coastguard Worker    * <li> As return value for <code>ubidi_getBaseDirection()</code>, it
437*0e209d39SAndroid Build Coastguard Worker    *      means that the first strong character of the source string has
438*0e209d39SAndroid Build Coastguard Worker    *      a left-to-right direction.
439*0e209d39SAndroid Build Coastguard Worker    * </ul>
440*0e209d39SAndroid Build Coastguard Worker    * \xrefitem stable "Stable" "Stable List" ICU 2.0
441*0e209d39SAndroid Build Coastguard Worker    */
442*0e209d39SAndroid Build Coastguard Worker   UBIDI_LTR,
443*0e209d39SAndroid Build Coastguard Worker   /** Right-to-left text. This is a 1 value.
444*0e209d39SAndroid Build Coastguard Worker    * <ul>
445*0e209d39SAndroid Build Coastguard Worker    * <li>As return value for <code>ubidi_getDirection()</code>, it means
446*0e209d39SAndroid Build Coastguard Worker    *     that the source string contains no left-to-right characters, or
447*0e209d39SAndroid Build Coastguard Worker    *     that the source string is empty and the paragraph level is odd.
448*0e209d39SAndroid Build Coastguard Worker    * <li> As return value for <code>ubidi_getBaseDirection()</code>, it
449*0e209d39SAndroid Build Coastguard Worker    *      means that the first strong character of the source string has
450*0e209d39SAndroid Build Coastguard Worker    *      a right-to-left direction.
451*0e209d39SAndroid Build Coastguard Worker    * </ul>
452*0e209d39SAndroid Build Coastguard Worker    * \xrefitem stable "Stable" "Stable List" ICU 2.0
453*0e209d39SAndroid Build Coastguard Worker    */
454*0e209d39SAndroid Build Coastguard Worker   UBIDI_RTL,
455*0e209d39SAndroid Build Coastguard Worker   /** Mixed-directional text.
456*0e209d39SAndroid Build Coastguard Worker    * <p>As return value for <code>ubidi_getDirection()</code>, it means
457*0e209d39SAndroid Build Coastguard Worker    *    that the source string contains both left-to-right and
458*0e209d39SAndroid Build Coastguard Worker    *    right-to-left characters.
459*0e209d39SAndroid Build Coastguard Worker    * \xrefitem stable "Stable" "Stable List" ICU 2.0
460*0e209d39SAndroid Build Coastguard Worker    */
461*0e209d39SAndroid Build Coastguard Worker   UBIDI_MIXED,
462*0e209d39SAndroid Build Coastguard Worker   /** No strongly directional text.
463*0e209d39SAndroid Build Coastguard Worker    * <p>As return value for <code>ubidi_getBaseDirection()</code>, it means
464*0e209d39SAndroid Build Coastguard Worker    *    that the source string is missing or empty, or contains neither left-to-right
465*0e209d39SAndroid Build Coastguard Worker    *    nor right-to-left characters.
466*0e209d39SAndroid Build Coastguard Worker    * \xrefitem stable "Stable" "Stable List" ICU 4.6
467*0e209d39SAndroid Build Coastguard Worker    */
468*0e209d39SAndroid Build Coastguard Worker   UBIDI_NEUTRAL
469*0e209d39SAndroid Build Coastguard Worker };
470*0e209d39SAndroid Build Coastguard Worker 
471*0e209d39SAndroid Build Coastguard Worker /** \xrefitem stable "Stable" "Stable List" ICU 2.0 */
472*0e209d39SAndroid Build Coastguard Worker typedef enum UBiDiDirection UBiDiDirection;
473*0e209d39SAndroid Build Coastguard Worker 
474*0e209d39SAndroid Build Coastguard Worker /**
475*0e209d39SAndroid Build Coastguard Worker  * Forward declaration of the <code>UBiDi</code> structure for the declaration of
476*0e209d39SAndroid Build Coastguard Worker  * the API functions. Its fields are implementation-specific.<p>
477*0e209d39SAndroid Build Coastguard Worker  * This structure holds information about a paragraph (or multiple paragraphs)
478*0e209d39SAndroid Build Coastguard Worker  * of text with Bidi-algorithm-related details, or about one line of
479*0e209d39SAndroid Build Coastguard Worker  * such a paragraph.<p>
480*0e209d39SAndroid Build Coastguard Worker  * Reordering can be done on a line, or on one or more paragraphs which are
481*0e209d39SAndroid Build Coastguard Worker  * then interpreted each as one single line.
482*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
483*0e209d39SAndroid Build Coastguard Worker  */
484*0e209d39SAndroid Build Coastguard Worker struct UBiDi;
485*0e209d39SAndroid Build Coastguard Worker 
486*0e209d39SAndroid Build Coastguard Worker /** \xrefitem stable "Stable" "Stable List" ICU 2.0 */
487*0e209d39SAndroid Build Coastguard Worker typedef struct UBiDi UBiDi;
488*0e209d39SAndroid Build Coastguard Worker 
489*0e209d39SAndroid Build Coastguard Worker /**
490*0e209d39SAndroid Build Coastguard Worker  * Allocate a <code>UBiDi</code> structure.
491*0e209d39SAndroid Build Coastguard Worker  * Such an object is initially empty. It is assigned
492*0e209d39SAndroid Build Coastguard Worker  * the Bidi properties of a piece of text containing one or more paragraphs
493*0e209d39SAndroid Build Coastguard Worker  * by <code>ubidi_setPara()</code>
494*0e209d39SAndroid Build Coastguard Worker  * or the Bidi properties of a line within a paragraph by
495*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setLine()</code>.<p>
496*0e209d39SAndroid Build Coastguard Worker  * This object can be reused for as long as it is not deallocated
497*0e209d39SAndroid Build Coastguard Worker  * by calling <code>ubidi_close()</code>.<p>
498*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setPara()</code> and <code>ubidi_setLine()</code> will allocate
499*0e209d39SAndroid Build Coastguard Worker  * additional memory for internal structures as necessary.
500*0e209d39SAndroid Build Coastguard Worker  *
501*0e209d39SAndroid Build Coastguard Worker  * @return An empty <code>UBiDi</code> object.
502*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
503*0e209d39SAndroid Build Coastguard Worker  */
504*0e209d39SAndroid Build Coastguard Worker U_CAPI UBiDi * U_EXPORT2
505*0e209d39SAndroid Build Coastguard Worker ubidi_open(void) __INTRODUCED_IN(31);
506*0e209d39SAndroid Build Coastguard Worker 
507*0e209d39SAndroid Build Coastguard Worker 
508*0e209d39SAndroid Build Coastguard Worker 
509*0e209d39SAndroid Build Coastguard Worker /**
510*0e209d39SAndroid Build Coastguard Worker  * Allocate a <code>UBiDi</code> structure with preallocated memory
511*0e209d39SAndroid Build Coastguard Worker  * for internal structures.
512*0e209d39SAndroid Build Coastguard Worker  * This function provides a <code>UBiDi</code> object like <code>ubidi_open()</code>
513*0e209d39SAndroid Build Coastguard Worker  * with no arguments, but it also preallocates memory for internal structures
514*0e209d39SAndroid Build Coastguard Worker  * according to the sizings supplied by the caller.<p>
515*0e209d39SAndroid Build Coastguard Worker  * Subsequent functions will not allocate any more memory, and are thus
516*0e209d39SAndroid Build Coastguard Worker  * guaranteed not to fail because of lack of memory.<p>
517*0e209d39SAndroid Build Coastguard Worker  * The preallocation can be limited to some of the internal memory
518*0e209d39SAndroid Build Coastguard Worker  * by setting some values to 0 here. That means that if, e.g.,
519*0e209d39SAndroid Build Coastguard Worker  * <code>maxRunCount</code> cannot be reasonably predetermined and should not
520*0e209d39SAndroid Build Coastguard Worker  * be set to <code>maxLength</code> (the only failproof value) to avoid
521*0e209d39SAndroid Build Coastguard Worker  * wasting memory, then <code>maxRunCount</code> could be set to 0 here
522*0e209d39SAndroid Build Coastguard Worker  * and the internal structures that are associated with it will be allocated
523*0e209d39SAndroid Build Coastguard Worker  * on demand, just like with <code>ubidi_open()</code>.
524*0e209d39SAndroid Build Coastguard Worker  *
525*0e209d39SAndroid Build Coastguard Worker  * @param maxLength is the maximum text or line length that internal memory
526*0e209d39SAndroid Build Coastguard Worker  *        will be preallocated for. An attempt to associate this object with a
527*0e209d39SAndroid Build Coastguard Worker  *        longer text will fail, unless this value is 0, which leaves the allocation
528*0e209d39SAndroid Build Coastguard Worker  *        up to the implementation.
529*0e209d39SAndroid Build Coastguard Worker  *
530*0e209d39SAndroid Build Coastguard Worker  * @param maxRunCount is the maximum anticipated number of same-level runs
531*0e209d39SAndroid Build Coastguard Worker  *        that internal memory will be preallocated for. An attempt to access
532*0e209d39SAndroid Build Coastguard Worker  *        visual runs on an object that was not preallocated for as many runs
533*0e209d39SAndroid Build Coastguard Worker  *        as the text was actually resolved to will fail,
534*0e209d39SAndroid Build Coastguard Worker  *        unless this value is 0, which leaves the allocation up to the implementation.<br><br>
535*0e209d39SAndroid Build Coastguard Worker  *        The number of runs depends on the actual text and maybe anywhere between
536*0e209d39SAndroid Build Coastguard Worker  *        1 and <code>maxLength</code>. It is typically small.
537*0e209d39SAndroid Build Coastguard Worker  *
538*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
539*0e209d39SAndroid Build Coastguard Worker  *
540*0e209d39SAndroid Build Coastguard Worker  * @return An empty <code>UBiDi</code> object with preallocated memory.
541*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
542*0e209d39SAndroid Build Coastguard Worker  */
543*0e209d39SAndroid Build Coastguard Worker U_CAPI UBiDi * U_EXPORT2
544*0e209d39SAndroid Build Coastguard Worker ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode) __INTRODUCED_IN(31);
545*0e209d39SAndroid Build Coastguard Worker 
546*0e209d39SAndroid Build Coastguard Worker 
547*0e209d39SAndroid Build Coastguard Worker 
548*0e209d39SAndroid Build Coastguard Worker /**
549*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_close()</code> must be called to free the memory
550*0e209d39SAndroid Build Coastguard Worker  * associated with a UBiDi object.<p>
551*0e209d39SAndroid Build Coastguard Worker  *
552*0e209d39SAndroid Build Coastguard Worker  * <strong>Important: </strong>
553*0e209d39SAndroid Build Coastguard Worker  * A parent <code>UBiDi</code> object must not be destroyed or reused if
554*0e209d39SAndroid Build Coastguard Worker  * it still has children.
555*0e209d39SAndroid Build Coastguard Worker  * If a <code>UBiDi</code> object has become the <i>child</i>
556*0e209d39SAndroid Build Coastguard Worker  * of another one (its <i>parent</i>) by calling
557*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setLine()</code>, then the child object must
558*0e209d39SAndroid Build Coastguard Worker  * be destroyed (closed) or reused (by calling
559*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setPara()</code> or <code>ubidi_setLine()</code>)
560*0e209d39SAndroid Build Coastguard Worker  * before the parent object.
561*0e209d39SAndroid Build Coastguard Worker  *
562*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is a <code>UBiDi</code> object.
563*0e209d39SAndroid Build Coastguard Worker  *
564*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setPara
565*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setLine
566*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
567*0e209d39SAndroid Build Coastguard Worker  */
568*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
569*0e209d39SAndroid Build Coastguard Worker ubidi_close(UBiDi *pBiDi) __INTRODUCED_IN(31);
570*0e209d39SAndroid Build Coastguard Worker 
571*0e209d39SAndroid Build Coastguard Worker 
572*0e209d39SAndroid Build Coastguard Worker 
573*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
574*0e209d39SAndroid Build Coastguard Worker 
575*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
576*0e209d39SAndroid Build Coastguard Worker 
577*0e209d39SAndroid Build Coastguard Worker /**
578*0e209d39SAndroid Build Coastguard Worker  * \class LocalUBiDiPointer
579*0e209d39SAndroid Build Coastguard Worker  * "Smart pointer" class, closes a UBiDi via ubidi_close().
580*0e209d39SAndroid Build Coastguard Worker  * For most methods see the LocalPointerBase base class.
581*0e209d39SAndroid Build Coastguard Worker  *
582*0e209d39SAndroid Build Coastguard Worker  * @see LocalPointerBase
583*0e209d39SAndroid Build Coastguard Worker  * @see LocalPointer
584*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 4.4
585*0e209d39SAndroid Build Coastguard Worker  */
586*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUBiDiPointer, UBiDi, ubidi_close);
587*0e209d39SAndroid Build Coastguard Worker 
588*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
589*0e209d39SAndroid Build Coastguard Worker 
590*0e209d39SAndroid Build Coastguard Worker #endif
591*0e209d39SAndroid Build Coastguard Worker 
592*0e209d39SAndroid Build Coastguard Worker /**
593*0e209d39SAndroid Build Coastguard Worker  * Modify the operation of the Bidi algorithm such that it
594*0e209d39SAndroid Build Coastguard Worker  * approximates an "inverse Bidi" algorithm. This function
595*0e209d39SAndroid Build Coastguard Worker  * must be called before <code>ubidi_setPara()</code>.
596*0e209d39SAndroid Build Coastguard Worker  *
597*0e209d39SAndroid Build Coastguard Worker  * <p>The normal operation of the Bidi algorithm as described
598*0e209d39SAndroid Build Coastguard Worker  * in the Unicode Technical Report is to take text stored in logical
599*0e209d39SAndroid Build Coastguard Worker  * (keyboard, typing) order and to determine the reordering of it for visual
600*0e209d39SAndroid Build Coastguard Worker  * rendering.
601*0e209d39SAndroid Build Coastguard Worker  * Some legacy systems store text in visual order, and for operations
602*0e209d39SAndroid Build Coastguard Worker  * with standard, Unicode-based algorithms, the text needs to be transformed
603*0e209d39SAndroid Build Coastguard Worker  * to logical order. This is effectively the inverse algorithm of the
604*0e209d39SAndroid Build Coastguard Worker  * described Bidi algorithm. Note that there is no standard algorithm for
605*0e209d39SAndroid Build Coastguard Worker  * this "inverse Bidi" and that the current implementation provides only an
606*0e209d39SAndroid Build Coastguard Worker  * approximation of "inverse Bidi".</p>
607*0e209d39SAndroid Build Coastguard Worker  *
608*0e209d39SAndroid Build Coastguard Worker  * <p>With <code>isInverse</code> set to <code>true</code>,
609*0e209d39SAndroid Build Coastguard Worker  * this function changes the behavior of some of the subsequent functions
610*0e209d39SAndroid Build Coastguard Worker  * in a way that they can be used for the inverse Bidi algorithm.
611*0e209d39SAndroid Build Coastguard Worker  * Specifically, runs of text with numeric characters will be treated in a
612*0e209d39SAndroid Build Coastguard Worker  * special way and may need to be surrounded with LRM characters when they are
613*0e209d39SAndroid Build Coastguard Worker  * written in reordered sequence.</p>
614*0e209d39SAndroid Build Coastguard Worker  *
615*0e209d39SAndroid Build Coastguard Worker  * <p>Output runs should be retrieved using <code>ubidi_getVisualRun()</code>.
616*0e209d39SAndroid Build Coastguard Worker  * Since the actual input for "inverse Bidi" is visually ordered text and
617*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_getVisualRun()</code> gets the reordered runs, these are actually
618*0e209d39SAndroid Build Coastguard Worker  * the runs of the logically ordered output.</p>
619*0e209d39SAndroid Build Coastguard Worker  *
620*0e209d39SAndroid Build Coastguard Worker  * <p>Calling this function with argument <code>isInverse</code> set to
621*0e209d39SAndroid Build Coastguard Worker  * <code>true</code> is equivalent to calling
622*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setReorderingMode</code> with argument
623*0e209d39SAndroid Build Coastguard Worker  * <code>reorderingMode</code>
624*0e209d39SAndroid Build Coastguard Worker  * set to <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>.<br>
625*0e209d39SAndroid Build Coastguard Worker  * Calling this function with argument <code>isInverse</code> set to
626*0e209d39SAndroid Build Coastguard Worker  * <code>false</code> is equivalent to calling
627*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setReorderingMode</code> with argument
628*0e209d39SAndroid Build Coastguard Worker  * <code>reorderingMode</code>
629*0e209d39SAndroid Build Coastguard Worker  * set to <code>#UBIDI_REORDER_DEFAULT</code>.
630*0e209d39SAndroid Build Coastguard Worker  *
631*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is a <code>UBiDi</code> object.
632*0e209d39SAndroid Build Coastguard Worker  *
633*0e209d39SAndroid Build Coastguard Worker  * @param isInverse specifies "forward" or "inverse" Bidi operation.
634*0e209d39SAndroid Build Coastguard Worker  *
635*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setPara
636*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_writeReordered
637*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setReorderingMode
638*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
639*0e209d39SAndroid Build Coastguard Worker  */
640*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
641*0e209d39SAndroid Build Coastguard Worker ubidi_setInverse(UBiDi *pBiDi, UBool isInverse) __INTRODUCED_IN(31);
642*0e209d39SAndroid Build Coastguard Worker 
643*0e209d39SAndroid Build Coastguard Worker 
644*0e209d39SAndroid Build Coastguard Worker 
645*0e209d39SAndroid Build Coastguard Worker /**
646*0e209d39SAndroid Build Coastguard Worker  * Is this Bidi object set to perform the inverse Bidi algorithm?
647*0e209d39SAndroid Build Coastguard Worker  * <p>Note: calling this function after setting the reordering mode with
648*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setReorderingMode</code> will return <code>true</code> if the
649*0e209d39SAndroid Build Coastguard Worker  * reordering mode was set to <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>,
650*0e209d39SAndroid Build Coastguard Worker  * <code>false</code> for all other values.</p>
651*0e209d39SAndroid Build Coastguard Worker  *
652*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is a <code>UBiDi</code> object.
653*0e209d39SAndroid Build Coastguard Worker  * @return true if the Bidi object is set to perform the inverse Bidi algorithm
654*0e209d39SAndroid Build Coastguard Worker  * by handling numbers as L.
655*0e209d39SAndroid Build Coastguard Worker  *
656*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setInverse
657*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setReorderingMode
658*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
659*0e209d39SAndroid Build Coastguard Worker  */
660*0e209d39SAndroid Build Coastguard Worker 
661*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
662*0e209d39SAndroid Build Coastguard Worker ubidi_isInverse(UBiDi *pBiDi);
663*0e209d39SAndroid Build Coastguard Worker 
664*0e209d39SAndroid Build Coastguard Worker /**
665*0e209d39SAndroid Build Coastguard Worker  * Specify whether block separators must be allocated level zero,
666*0e209d39SAndroid Build Coastguard Worker  * so that successive paragraphs will progress from left to right.
667*0e209d39SAndroid Build Coastguard Worker  * This function must be called before <code>ubidi_setPara()</code>.
668*0e209d39SAndroid Build Coastguard Worker  * Paragraph separators (B) may appear in the text.  Setting them to level zero
669*0e209d39SAndroid Build Coastguard Worker  * means that all paragraph separators (including one possibly appearing
670*0e209d39SAndroid Build Coastguard Worker  * in the last text position) are kept in the reordered text after the text
671*0e209d39SAndroid Build Coastguard Worker  * that they follow in the source text.
672*0e209d39SAndroid Build Coastguard Worker  * When this feature is not enabled, a paragraph separator at the last
673*0e209d39SAndroid Build Coastguard Worker  * position of the text before reordering will go to the first position
674*0e209d39SAndroid Build Coastguard Worker  * of the reordered text when the paragraph level is odd.
675*0e209d39SAndroid Build Coastguard Worker  *
676*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is a <code>UBiDi</code> object.
677*0e209d39SAndroid Build Coastguard Worker  *
678*0e209d39SAndroid Build Coastguard Worker  * @param orderParagraphsLTR specifies whether paragraph separators (B) must
679*0e209d39SAndroid Build Coastguard Worker  * receive level 0, so that successive paragraphs progress from left to right.
680*0e209d39SAndroid Build Coastguard Worker  *
681*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setPara
682*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.4
683*0e209d39SAndroid Build Coastguard Worker  */
684*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
685*0e209d39SAndroid Build Coastguard Worker ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR) __INTRODUCED_IN(31);
686*0e209d39SAndroid Build Coastguard Worker 
687*0e209d39SAndroid Build Coastguard Worker 
688*0e209d39SAndroid Build Coastguard Worker 
689*0e209d39SAndroid Build Coastguard Worker /**
690*0e209d39SAndroid Build Coastguard Worker  * Is this Bidi object set to allocate level 0 to block separators so that
691*0e209d39SAndroid Build Coastguard Worker  * successive paragraphs progress from left to right?
692*0e209d39SAndroid Build Coastguard Worker  *
693*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is a <code>UBiDi</code> object.
694*0e209d39SAndroid Build Coastguard Worker  * @return true if the Bidi object is set to allocate level 0 to block
695*0e209d39SAndroid Build Coastguard Worker  *         separators.
696*0e209d39SAndroid Build Coastguard Worker  *
697*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_orderParagraphsLTR
698*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.4
699*0e209d39SAndroid Build Coastguard Worker  */
700*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2
701*0e209d39SAndroid Build Coastguard Worker ubidi_isOrderParagraphsLTR(UBiDi *pBiDi) __INTRODUCED_IN(31);
702*0e209d39SAndroid Build Coastguard Worker 
703*0e209d39SAndroid Build Coastguard Worker 
704*0e209d39SAndroid Build Coastguard Worker 
705*0e209d39SAndroid Build Coastguard Worker /**
706*0e209d39SAndroid Build Coastguard Worker  * <code>UBiDiReorderingMode</code> values indicate which variant of the Bidi
707*0e209d39SAndroid Build Coastguard Worker  * algorithm to use.
708*0e209d39SAndroid Build Coastguard Worker  *
709*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setReorderingMode
710*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
711*0e209d39SAndroid Build Coastguard Worker  */
712*0e209d39SAndroid Build Coastguard Worker typedef enum UBiDiReorderingMode {
713*0e209d39SAndroid Build Coastguard Worker     /** Regular Logical to Visual Bidi algorithm according to Unicode.
714*0e209d39SAndroid Build Coastguard Worker       * This is a 0 value.
715*0e209d39SAndroid Build Coastguard Worker       * \xrefitem stable "Stable" "Stable List" ICU 3.6 */
716*0e209d39SAndroid Build Coastguard Worker     UBIDI_REORDER_DEFAULT = 0,
717*0e209d39SAndroid Build Coastguard Worker     /** Logical to Visual algorithm which handles numbers in a way which
718*0e209d39SAndroid Build Coastguard Worker       * mimics the behavior of Windows XP.
719*0e209d39SAndroid Build Coastguard Worker       * \xrefitem stable "Stable" "Stable List" ICU 3.6 */
720*0e209d39SAndroid Build Coastguard Worker     UBIDI_REORDER_NUMBERS_SPECIAL,
721*0e209d39SAndroid Build Coastguard Worker     /** Logical to Visual algorithm grouping numbers with adjacent R characters
722*0e209d39SAndroid Build Coastguard Worker       * (reversible algorithm).
723*0e209d39SAndroid Build Coastguard Worker       * \xrefitem stable "Stable" "Stable List" ICU 3.6 */
724*0e209d39SAndroid Build Coastguard Worker     UBIDI_REORDER_GROUP_NUMBERS_WITH_R,
725*0e209d39SAndroid Build Coastguard Worker     /** Reorder runs only to transform a Logical LTR string to the Logical RTL
726*0e209d39SAndroid Build Coastguard Worker       * string with the same display, or vice-versa.<br>
727*0e209d39SAndroid Build Coastguard Worker       * If this mode is set together with option
728*0e209d39SAndroid Build Coastguard Worker       * <code>#UBIDI_OPTION_INSERT_MARKS</code>, some Bidi controls in the source
729*0e209d39SAndroid Build Coastguard Worker       * text may be removed and other controls may be added to produce the
730*0e209d39SAndroid Build Coastguard Worker       * minimum combination which has the required display.
731*0e209d39SAndroid Build Coastguard Worker       * \xrefitem stable "Stable" "Stable List" ICU 3.6 */
732*0e209d39SAndroid Build Coastguard Worker     UBIDI_REORDER_RUNS_ONLY,
733*0e209d39SAndroid Build Coastguard Worker     /** Visual to Logical algorithm which handles numbers like L
734*0e209d39SAndroid Build Coastguard Worker       * (same algorithm as selected by <code>ubidi_setInverse(true)</code>.
735*0e209d39SAndroid Build Coastguard Worker       * @see ubidi_setInverse
736*0e209d39SAndroid Build Coastguard Worker       * \xrefitem stable "Stable" "Stable List" ICU 3.6 */
737*0e209d39SAndroid Build Coastguard Worker     UBIDI_REORDER_INVERSE_NUMBERS_AS_L,
738*0e209d39SAndroid Build Coastguard Worker     /** Visual to Logical algorithm equivalent to the regular Logical to Visual
739*0e209d39SAndroid Build Coastguard Worker       * algorithm.
740*0e209d39SAndroid Build Coastguard Worker       * \xrefitem stable "Stable" "Stable List" ICU 3.6 */
741*0e209d39SAndroid Build Coastguard Worker     UBIDI_REORDER_INVERSE_LIKE_DIRECT,
742*0e209d39SAndroid Build Coastguard Worker     /** Inverse Bidi (Visual to Logical) algorithm for the
743*0e209d39SAndroid Build Coastguard Worker       * <code>UBIDI_REORDER_NUMBERS_SPECIAL</code> Bidi algorithm.
744*0e209d39SAndroid Build Coastguard Worker       * \xrefitem stable "Stable" "Stable List" ICU 3.6 */
745*0e209d39SAndroid Build Coastguard Worker     UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL,
746*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API
747*0e209d39SAndroid Build Coastguard Worker     /**
748*0e209d39SAndroid Build Coastguard Worker      * Number of values for reordering mode.
749*0e209d39SAndroid Build Coastguard Worker      * \xrefitem deprecated "Deprecated" "Deprecated List" ICU 58 The numeric value may change over time, see ICU ticket #12420.
750*0e209d39SAndroid Build Coastguard Worker      */
751*0e209d39SAndroid Build Coastguard Worker     UBIDI_REORDER_COUNT
752*0e209d39SAndroid Build Coastguard Worker #endif  // U_HIDE_DEPRECATED_API
753*0e209d39SAndroid Build Coastguard Worker } UBiDiReorderingMode;
754*0e209d39SAndroid Build Coastguard Worker 
755*0e209d39SAndroid Build Coastguard Worker /**
756*0e209d39SAndroid Build Coastguard Worker  * Modify the operation of the Bidi algorithm such that it implements some
757*0e209d39SAndroid Build Coastguard Worker  * variant to the basic Bidi algorithm or approximates an "inverse Bidi"
758*0e209d39SAndroid Build Coastguard Worker  * algorithm, depending on different values of the "reordering mode".
759*0e209d39SAndroid Build Coastguard Worker  * This function must be called before <code>ubidi_setPara()</code>, and stays
760*0e209d39SAndroid Build Coastguard Worker  * in effect until called again with a different argument.
761*0e209d39SAndroid Build Coastguard Worker  *
762*0e209d39SAndroid Build Coastguard Worker  * <p>The normal operation of the Bidi algorithm as described
763*0e209d39SAndroid Build Coastguard Worker  * in the Unicode Standard Annex #9 is to take text stored in logical
764*0e209d39SAndroid Build Coastguard Worker  * (keyboard, typing) order and to determine how to reorder it for visual
765*0e209d39SAndroid Build Coastguard Worker  * rendering.</p>
766*0e209d39SAndroid Build Coastguard Worker  *
767*0e209d39SAndroid Build Coastguard Worker  * <p>With the reordering mode set to a value other than
768*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_REORDER_DEFAULT</code>, this function changes the behavior of
769*0e209d39SAndroid Build Coastguard Worker  * some of the subsequent functions in a way such that they implement an
770*0e209d39SAndroid Build Coastguard Worker  * inverse Bidi algorithm or some other algorithm variants.</p>
771*0e209d39SAndroid Build Coastguard Worker  *
772*0e209d39SAndroid Build Coastguard Worker  * <p>Some legacy systems store text in visual order, and for operations
773*0e209d39SAndroid Build Coastguard Worker  * with standard, Unicode-based algorithms, the text needs to be transformed
774*0e209d39SAndroid Build Coastguard Worker  * into logical order. This is effectively the inverse algorithm of the
775*0e209d39SAndroid Build Coastguard Worker  * described Bidi algorithm. Note that there is no standard algorithm for
776*0e209d39SAndroid Build Coastguard Worker  * this "inverse Bidi", so a number of variants are implemented here.</p>
777*0e209d39SAndroid Build Coastguard Worker  *
778*0e209d39SAndroid Build Coastguard Worker  * <p>In other cases, it may be desirable to emulate some variant of the
779*0e209d39SAndroid Build Coastguard Worker  * Logical to Visual algorithm (e.g. one used in MS Windows), or perform a
780*0e209d39SAndroid Build Coastguard Worker  * Logical to Logical transformation.</p>
781*0e209d39SAndroid Build Coastguard Worker  *
782*0e209d39SAndroid Build Coastguard Worker  * <ul>
783*0e209d39SAndroid Build Coastguard Worker  * <li>When the reordering mode is set to <code>#UBIDI_REORDER_DEFAULT</code>,
784*0e209d39SAndroid Build Coastguard Worker  * the standard Bidi Logical to Visual algorithm is applied.</li>
785*0e209d39SAndroid Build Coastguard Worker  *
786*0e209d39SAndroid Build Coastguard Worker  * <li>When the reordering mode is set to
787*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_REORDER_NUMBERS_SPECIAL</code>,
788*0e209d39SAndroid Build Coastguard Worker  * the algorithm used to perform Bidi transformations when calling
789*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setPara</code> should approximate the algorithm used in
790*0e209d39SAndroid Build Coastguard Worker  * Microsoft Windows XP rather than strictly conform to the Unicode Bidi
791*0e209d39SAndroid Build Coastguard Worker  * algorithm.
792*0e209d39SAndroid Build Coastguard Worker  * <br>
793*0e209d39SAndroid Build Coastguard Worker  * The differences between the basic algorithm and the algorithm addressed
794*0e209d39SAndroid Build Coastguard Worker  * by this option are as follows:
795*0e209d39SAndroid Build Coastguard Worker  * <ul>
796*0e209d39SAndroid Build Coastguard Worker  *   <li>Within text at an even embedding level, the sequence "123AB"
797*0e209d39SAndroid Build Coastguard Worker  *   (where AB represent R or AL letters) is transformed to "123BA" by the
798*0e209d39SAndroid Build Coastguard Worker  *   Unicode algorithm and to "BA123" by the Windows algorithm.</li>
799*0e209d39SAndroid Build Coastguard Worker  *   <li>Arabic-Indic numbers (AN) are handled by the Windows algorithm just
800*0e209d39SAndroid Build Coastguard Worker  *   like regular numbers (EN).</li>
801*0e209d39SAndroid Build Coastguard Worker  * </ul></li>
802*0e209d39SAndroid Build Coastguard Worker  *
803*0e209d39SAndroid Build Coastguard Worker  * <li>When the reordering mode is set to
804*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_REORDER_GROUP_NUMBERS_WITH_R</code>,
805*0e209d39SAndroid Build Coastguard Worker  * numbers located between LTR text and RTL text are associated with the RTL
806*0e209d39SAndroid Build Coastguard Worker  * text. For instance, an LTR paragraph with content "abc 123 DEF" (where
807*0e209d39SAndroid Build Coastguard Worker  * upper case letters represent RTL characters) will be transformed to
808*0e209d39SAndroid Build Coastguard Worker  * "abc FED 123" (and not "abc 123 FED"), "DEF 123 abc" will be transformed
809*0e209d39SAndroid Build Coastguard Worker  * to "123 FED abc" and "123 FED abc" will be transformed to "DEF 123 abc".
810*0e209d39SAndroid Build Coastguard Worker  * This makes the algorithm reversible and makes it useful when round trip
811*0e209d39SAndroid Build Coastguard Worker  * (from visual to logical and back to visual) must be achieved without
812*0e209d39SAndroid Build Coastguard Worker  * adding LRM characters. However, this is a variation from the standard
813*0e209d39SAndroid Build Coastguard Worker  * Unicode Bidi algorithm.<br>
814*0e209d39SAndroid Build Coastguard Worker  * The source text should not contain Bidi control characters other than LRM
815*0e209d39SAndroid Build Coastguard Worker  * or RLM.</li>
816*0e209d39SAndroid Build Coastguard Worker  *
817*0e209d39SAndroid Build Coastguard Worker  * <li>When the reordering mode is set to
818*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_REORDER_RUNS_ONLY</code>,
819*0e209d39SAndroid Build Coastguard Worker  * a "Logical to Logical" transformation must be performed:
820*0e209d39SAndroid Build Coastguard Worker  * <ul>
821*0e209d39SAndroid Build Coastguard Worker  * <li>If the default text level of the source text (argument <code>paraLevel</code>
822*0e209d39SAndroid Build Coastguard Worker  * in <code>ubidi_setPara</code>) is even, the source text will be handled as
823*0e209d39SAndroid Build Coastguard Worker  * LTR logical text and will be transformed to the RTL logical text which has
824*0e209d39SAndroid Build Coastguard Worker  * the same LTR visual display.</li>
825*0e209d39SAndroid Build Coastguard Worker  * <li>If the default level of the source text is odd, the source text
826*0e209d39SAndroid Build Coastguard Worker  * will be handled as RTL logical text and will be transformed to the
827*0e209d39SAndroid Build Coastguard Worker  * LTR logical text which has the same LTR visual display.</li>
828*0e209d39SAndroid Build Coastguard Worker  * </ul>
829*0e209d39SAndroid Build Coastguard Worker  * This mode may be needed when logical text which is basically Arabic or
830*0e209d39SAndroid Build Coastguard Worker  * Hebrew, with possible included numbers or phrases in English, has to be
831*0e209d39SAndroid Build Coastguard Worker  * displayed as if it had an even embedding level (this can happen if the
832*0e209d39SAndroid Build Coastguard Worker  * displaying application treats all text as if it was basically LTR).
833*0e209d39SAndroid Build Coastguard Worker  * <br>
834*0e209d39SAndroid Build Coastguard Worker  * This mode may also be needed in the reverse case, when logical text which is
835*0e209d39SAndroid Build Coastguard Worker  * basically English, with possible included phrases in Arabic or Hebrew, has to
836*0e209d39SAndroid Build Coastguard Worker  * be displayed as if it had an odd embedding level.
837*0e209d39SAndroid Build Coastguard Worker  * <br>
838*0e209d39SAndroid Build Coastguard Worker  * Both cases could be handled by adding LRE or RLE at the head of the text,
839*0e209d39SAndroid Build Coastguard Worker  * if the display subsystem supports these formatting controls. If it does not,
840*0e209d39SAndroid Build Coastguard Worker  * the problem may be handled by transforming the source text in this mode
841*0e209d39SAndroid Build Coastguard Worker  * before displaying it, so that it will be displayed properly.<br>
842*0e209d39SAndroid Build Coastguard Worker  * The source text should not contain Bidi control characters other than LRM
843*0e209d39SAndroid Build Coastguard Worker  * or RLM.</li>
844*0e209d39SAndroid Build Coastguard Worker  *
845*0e209d39SAndroid Build Coastguard Worker  * <li>When the reordering mode is set to
846*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>, an "inverse Bidi" algorithm
847*0e209d39SAndroid Build Coastguard Worker  * is applied.
848*0e209d39SAndroid Build Coastguard Worker  * Runs of text with numeric characters will be treated like LTR letters and
849*0e209d39SAndroid Build Coastguard Worker  * may need to be surrounded with LRM characters when they are written in
850*0e209d39SAndroid Build Coastguard Worker  * reordered sequence (the option <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> can
851*0e209d39SAndroid Build Coastguard Worker  * be used with function <code>ubidi_writeReordered</code> to this end. This
852*0e209d39SAndroid Build Coastguard Worker  * mode is equivalent to calling <code>ubidi_setInverse()</code> with
853*0e209d39SAndroid Build Coastguard Worker  * argument <code>isInverse</code> set to <code>true</code>.</li>
854*0e209d39SAndroid Build Coastguard Worker  *
855*0e209d39SAndroid Build Coastguard Worker  * <li>When the reordering mode is set to
856*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_REORDER_INVERSE_LIKE_DIRECT</code>, the "direct" Logical to Visual
857*0e209d39SAndroid Build Coastguard Worker  * Bidi algorithm is used as an approximation of an "inverse Bidi" algorithm.
858*0e209d39SAndroid Build Coastguard Worker  * This mode is similar to mode <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>
859*0e209d39SAndroid Build Coastguard Worker  * but is closer to the regular Bidi algorithm.
860*0e209d39SAndroid Build Coastguard Worker  * <br>
861*0e209d39SAndroid Build Coastguard Worker  * For example, an LTR paragraph with the content "FED 123 456 CBA" (where
862*0e209d39SAndroid Build Coastguard Worker  * upper case represents RTL characters) will be transformed to
863*0e209d39SAndroid Build Coastguard Worker  * "ABC 456 123 DEF", as opposed to "DEF 123 456 ABC"
864*0e209d39SAndroid Build Coastguard Worker  * with mode <code>UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>.<br>
865*0e209d39SAndroid Build Coastguard Worker  * When used in conjunction with option
866*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_OPTION_INSERT_MARKS</code>, this mode generally
867*0e209d39SAndroid Build Coastguard Worker  * adds Bidi marks to the output significantly more sparingly than mode
868*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code> with option
869*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> in calls to
870*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_writeReordered</code>.</li>
871*0e209d39SAndroid Build Coastguard Worker  *
872*0e209d39SAndroid Build Coastguard Worker  * <li>When the reordering mode is set to
873*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code>, the Logical to Visual
874*0e209d39SAndroid Build Coastguard Worker  * Bidi algorithm used in Windows XP is used as an approximation of an "inverse Bidi" algorithm.
875*0e209d39SAndroid Build Coastguard Worker  * <br>
876*0e209d39SAndroid Build Coastguard Worker  * For example, an LTR paragraph with the content "abc FED123" (where
877*0e209d39SAndroid Build Coastguard Worker  * upper case represents RTL characters) will be transformed to "abc 123DEF."</li>
878*0e209d39SAndroid Build Coastguard Worker  * </ul>
879*0e209d39SAndroid Build Coastguard Worker  *
880*0e209d39SAndroid Build Coastguard Worker  * <p>In all the reordering modes specifying an "inverse Bidi" algorithm
881*0e209d39SAndroid Build Coastguard Worker  * (i.e. those with a name starting with <code>UBIDI_REORDER_INVERSE</code>),
882*0e209d39SAndroid Build Coastguard Worker  * output runs should be retrieved using
883*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_getVisualRun()</code>, and the output text with
884*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_writeReordered()</code>. The caller should keep in mind that in
885*0e209d39SAndroid Build Coastguard Worker  * "inverse Bidi" modes the input is actually visually ordered text and
886*0e209d39SAndroid Build Coastguard Worker  * reordered output returned by <code>ubidi_getVisualRun()</code> or
887*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_writeReordered()</code> are actually runs or character string
888*0e209d39SAndroid Build Coastguard Worker  * of logically ordered output.<br>
889*0e209d39SAndroid Build Coastguard Worker  * For all the "inverse Bidi" modes, the source text should not contain
890*0e209d39SAndroid Build Coastguard Worker  * Bidi control characters other than LRM or RLM.</p>
891*0e209d39SAndroid Build Coastguard Worker  *
892*0e209d39SAndroid Build Coastguard Worker  * <p>Note that option <code>#UBIDI_OUTPUT_REVERSE</code> of
893*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_writeReordered</code> has no useful meaning and should not be
894*0e209d39SAndroid Build Coastguard Worker  * used in conjunction with any value of the reordering mode specifying
895*0e209d39SAndroid Build Coastguard Worker  * "inverse Bidi" or with value <code>UBIDI_REORDER_RUNS_ONLY</code>.
896*0e209d39SAndroid Build Coastguard Worker  *
897*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is a <code>UBiDi</code> object.
898*0e209d39SAndroid Build Coastguard Worker  * @param reorderingMode specifies the required variant of the Bidi algorithm.
899*0e209d39SAndroid Build Coastguard Worker  *
900*0e209d39SAndroid Build Coastguard Worker  * @see UBiDiReorderingMode
901*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setInverse
902*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setPara
903*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_writeReordered
904*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
905*0e209d39SAndroid Build Coastguard Worker  */
906*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
907*0e209d39SAndroid Build Coastguard Worker ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode) __INTRODUCED_IN(31);
908*0e209d39SAndroid Build Coastguard Worker 
909*0e209d39SAndroid Build Coastguard Worker 
910*0e209d39SAndroid Build Coastguard Worker 
911*0e209d39SAndroid Build Coastguard Worker /**
912*0e209d39SAndroid Build Coastguard Worker  * What is the requested reordering mode for a given Bidi object?
913*0e209d39SAndroid Build Coastguard Worker  *
914*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is a <code>UBiDi</code> object.
915*0e209d39SAndroid Build Coastguard Worker  * @return the current reordering mode of the Bidi object
916*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setReorderingMode
917*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
918*0e209d39SAndroid Build Coastguard Worker  */
919*0e209d39SAndroid Build Coastguard Worker U_CAPI UBiDiReorderingMode U_EXPORT2
920*0e209d39SAndroid Build Coastguard Worker ubidi_getReorderingMode(UBiDi *pBiDi) __INTRODUCED_IN(31);
921*0e209d39SAndroid Build Coastguard Worker 
922*0e209d39SAndroid Build Coastguard Worker 
923*0e209d39SAndroid Build Coastguard Worker 
924*0e209d39SAndroid Build Coastguard Worker /**
925*0e209d39SAndroid Build Coastguard Worker  * <code>UBiDiReorderingOption</code> values indicate which options are
926*0e209d39SAndroid Build Coastguard Worker  * specified to affect the Bidi algorithm.
927*0e209d39SAndroid Build Coastguard Worker  *
928*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setReorderingOptions
929*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
930*0e209d39SAndroid Build Coastguard Worker  */
931*0e209d39SAndroid Build Coastguard Worker typedef enum UBiDiReorderingOption {
932*0e209d39SAndroid Build Coastguard Worker     /**
933*0e209d39SAndroid Build Coastguard Worker      * option value for <code>ubidi_setReorderingOptions</code>:
934*0e209d39SAndroid Build Coastguard Worker      * disable all the options which can be set with this function
935*0e209d39SAndroid Build Coastguard Worker      * @see ubidi_setReorderingOptions
936*0e209d39SAndroid Build Coastguard Worker      * \xrefitem stable "Stable" "Stable List" ICU 3.6
937*0e209d39SAndroid Build Coastguard Worker      */
938*0e209d39SAndroid Build Coastguard Worker     UBIDI_OPTION_DEFAULT = 0,
939*0e209d39SAndroid Build Coastguard Worker 
940*0e209d39SAndroid Build Coastguard Worker     /**
941*0e209d39SAndroid Build Coastguard Worker      * option bit for <code>ubidi_setReorderingOptions</code>:
942*0e209d39SAndroid Build Coastguard Worker      * insert Bidi marks (LRM or RLM) when needed to ensure correct result of
943*0e209d39SAndroid Build Coastguard Worker      * a reordering to a Logical order
944*0e209d39SAndroid Build Coastguard Worker      *
945*0e209d39SAndroid Build Coastguard Worker      * <p>This option must be set or reset before calling
946*0e209d39SAndroid Build Coastguard Worker      * <code>ubidi_setPara</code>.</p>
947*0e209d39SAndroid Build Coastguard Worker      *
948*0e209d39SAndroid Build Coastguard Worker      * <p>This option is significant only with reordering modes which generate
949*0e209d39SAndroid Build Coastguard Worker      * a result with Logical order, specifically:</p>
950*0e209d39SAndroid Build Coastguard Worker      * <ul>
951*0e209d39SAndroid Build Coastguard Worker      *   <li><code>#UBIDI_REORDER_RUNS_ONLY</code></li>
952*0e209d39SAndroid Build Coastguard Worker      *   <li><code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code></li>
953*0e209d39SAndroid Build Coastguard Worker      *   <li><code>#UBIDI_REORDER_INVERSE_LIKE_DIRECT</code></li>
954*0e209d39SAndroid Build Coastguard Worker      *   <li><code>#UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL</code></li>
955*0e209d39SAndroid Build Coastguard Worker      * </ul>
956*0e209d39SAndroid Build Coastguard Worker      *
957*0e209d39SAndroid Build Coastguard Worker      * <p>If this option is set in conjunction with reordering mode
958*0e209d39SAndroid Build Coastguard Worker      * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code> or with calling
959*0e209d39SAndroid Build Coastguard Worker      * <code>ubidi_setInverse(true)</code>, it implies
960*0e209d39SAndroid Build Coastguard Worker      * option <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code>
961*0e209d39SAndroid Build Coastguard Worker      * in calls to function <code>ubidi_writeReordered()</code>.</p>
962*0e209d39SAndroid Build Coastguard Worker      *
963*0e209d39SAndroid Build Coastguard Worker      * <p>For other reordering modes, a minimum number of LRM or RLM characters
964*0e209d39SAndroid Build Coastguard Worker      * will be added to the source text after reordering it so as to ensure
965*0e209d39SAndroid Build Coastguard Worker      * round trip, i.e. when applying the inverse reordering mode on the
966*0e209d39SAndroid Build Coastguard Worker      * resulting logical text with removal of Bidi marks
967*0e209d39SAndroid Build Coastguard Worker      * (option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> set before calling
968*0e209d39SAndroid Build Coastguard Worker      * <code>ubidi_setPara()</code> or option <code>#UBIDI_REMOVE_BIDI_CONTROLS</code>
969*0e209d39SAndroid Build Coastguard Worker      * in <code>ubidi_writeReordered</code>), the result will be identical to the
970*0e209d39SAndroid Build Coastguard Worker      * source text in the first transformation.
971*0e209d39SAndroid Build Coastguard Worker      *
972*0e209d39SAndroid Build Coastguard Worker      * <p>This option will be ignored if specified together with option
973*0e209d39SAndroid Build Coastguard Worker      * <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>. It inhibits option
974*0e209d39SAndroid Build Coastguard Worker      * <code>UBIDI_REMOVE_BIDI_CONTROLS</code> in calls to function
975*0e209d39SAndroid Build Coastguard Worker      * <code>ubidi_writeReordered()</code> and it implies option
976*0e209d39SAndroid Build Coastguard Worker      * <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> in calls to function
977*0e209d39SAndroid Build Coastguard Worker      * <code>ubidi_writeReordered()</code> if the reordering mode is
978*0e209d39SAndroid Build Coastguard Worker      * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code>.</p>
979*0e209d39SAndroid Build Coastguard Worker      *
980*0e209d39SAndroid Build Coastguard Worker      * @see ubidi_setReorderingMode
981*0e209d39SAndroid Build Coastguard Worker      * @see ubidi_setReorderingOptions
982*0e209d39SAndroid Build Coastguard Worker      * \xrefitem stable "Stable" "Stable List" ICU 3.6
983*0e209d39SAndroid Build Coastguard Worker      */
984*0e209d39SAndroid Build Coastguard Worker     UBIDI_OPTION_INSERT_MARKS = 1,
985*0e209d39SAndroid Build Coastguard Worker 
986*0e209d39SAndroid Build Coastguard Worker     /**
987*0e209d39SAndroid Build Coastguard Worker      * option bit for <code>ubidi_setReorderingOptions</code>:
988*0e209d39SAndroid Build Coastguard Worker      * remove Bidi control characters
989*0e209d39SAndroid Build Coastguard Worker      *
990*0e209d39SAndroid Build Coastguard Worker      * <p>This option must be set or reset before calling
991*0e209d39SAndroid Build Coastguard Worker      * <code>ubidi_setPara</code>.</p>
992*0e209d39SAndroid Build Coastguard Worker      *
993*0e209d39SAndroid Build Coastguard Worker      * <p>This option nullifies option <code>#UBIDI_OPTION_INSERT_MARKS</code>.
994*0e209d39SAndroid Build Coastguard Worker      * It inhibits option <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code> in calls
995*0e209d39SAndroid Build Coastguard Worker      * to function <code>ubidi_writeReordered()</code> and it implies option
996*0e209d39SAndroid Build Coastguard Worker      * <code>#UBIDI_REMOVE_BIDI_CONTROLS</code> in calls to that function.</p>
997*0e209d39SAndroid Build Coastguard Worker      *
998*0e209d39SAndroid Build Coastguard Worker      * @see ubidi_setReorderingMode
999*0e209d39SAndroid Build Coastguard Worker      * @see ubidi_setReorderingOptions
1000*0e209d39SAndroid Build Coastguard Worker      * \xrefitem stable "Stable" "Stable List" ICU 3.6
1001*0e209d39SAndroid Build Coastguard Worker      */
1002*0e209d39SAndroid Build Coastguard Worker     UBIDI_OPTION_REMOVE_CONTROLS = 2,
1003*0e209d39SAndroid Build Coastguard Worker 
1004*0e209d39SAndroid Build Coastguard Worker     /**
1005*0e209d39SAndroid Build Coastguard Worker      * option bit for <code>ubidi_setReorderingOptions</code>:
1006*0e209d39SAndroid Build Coastguard Worker      * process the output as part of a stream to be continued
1007*0e209d39SAndroid Build Coastguard Worker      *
1008*0e209d39SAndroid Build Coastguard Worker      * <p>This option must be set or reset before calling
1009*0e209d39SAndroid Build Coastguard Worker      * <code>ubidi_setPara</code>.</p>
1010*0e209d39SAndroid Build Coastguard Worker      *
1011*0e209d39SAndroid Build Coastguard Worker      * <p>This option specifies that the caller is interested in processing large
1012*0e209d39SAndroid Build Coastguard Worker      * text object in parts.
1013*0e209d39SAndroid Build Coastguard Worker      * The results of the successive calls are expected to be concatenated by the
1014*0e209d39SAndroid Build Coastguard Worker      * caller. Only the call for the last part will have this option bit off.</p>
1015*0e209d39SAndroid Build Coastguard Worker      *
1016*0e209d39SAndroid Build Coastguard Worker      * <p>When this option bit is on, <code>ubidi_setPara()</code> may process
1017*0e209d39SAndroid Build Coastguard Worker      * less than the full source text in order to truncate the text at a meaningful
1018*0e209d39SAndroid Build Coastguard Worker      * boundary. The caller should call <code>ubidi_getProcessedLength()</code>
1019*0e209d39SAndroid Build Coastguard Worker      * immediately after calling <code>ubidi_setPara()</code> in order to
1020*0e209d39SAndroid Build Coastguard Worker      * determine how much of the source text has been processed.
1021*0e209d39SAndroid Build Coastguard Worker      * Source text beyond that length should be resubmitted in following calls to
1022*0e209d39SAndroid Build Coastguard Worker      * <code>ubidi_setPara</code>. The processed length may be less than
1023*0e209d39SAndroid Build Coastguard Worker      * the length of the source text if a character preceding the last character of
1024*0e209d39SAndroid Build Coastguard Worker      * the source text constitutes a reasonable boundary (like a block separator)
1025*0e209d39SAndroid Build Coastguard Worker      * for text to be continued.<br>
1026*0e209d39SAndroid Build Coastguard Worker      * If the last character of the source text constitutes a reasonable
1027*0e209d39SAndroid Build Coastguard Worker      * boundary, the whole text will be processed at once.<br>
1028*0e209d39SAndroid Build Coastguard Worker      * If nowhere in the source text there exists
1029*0e209d39SAndroid Build Coastguard Worker      * such a reasonable boundary, the processed length will be zero.<br>
1030*0e209d39SAndroid Build Coastguard Worker      * The caller should check for such an occurrence and do one of the following:
1031*0e209d39SAndroid Build Coastguard Worker      * <ul><li>submit a larger amount of text with a better chance to include
1032*0e209d39SAndroid Build Coastguard Worker      *         a reasonable boundary.</li>
1033*0e209d39SAndroid Build Coastguard Worker      *     <li>resubmit the same text after turning off option
1034*0e209d39SAndroid Build Coastguard Worker      *         <code>UBIDI_OPTION_STREAMING</code>.</li></ul>
1035*0e209d39SAndroid Build Coastguard Worker      * In all cases, this option should be turned off before processing the last
1036*0e209d39SAndroid Build Coastguard Worker      * part of the text.</p>
1037*0e209d39SAndroid Build Coastguard Worker      *
1038*0e209d39SAndroid Build Coastguard Worker      * <p>When the <code>UBIDI_OPTION_STREAMING</code> option is used,
1039*0e209d39SAndroid Build Coastguard Worker      * it is recommended to call <code>ubidi_orderParagraphsLTR()</code> with
1040*0e209d39SAndroid Build Coastguard Worker      * argument <code>orderParagraphsLTR</code> set to <code>true</code> before
1041*0e209d39SAndroid Build Coastguard Worker      * calling <code>ubidi_setPara</code> so that later paragraphs may be
1042*0e209d39SAndroid Build Coastguard Worker      * concatenated to previous paragraphs on the right.</p>
1043*0e209d39SAndroid Build Coastguard Worker      *
1044*0e209d39SAndroid Build Coastguard Worker      * @see ubidi_setReorderingMode
1045*0e209d39SAndroid Build Coastguard Worker      * @see ubidi_setReorderingOptions
1046*0e209d39SAndroid Build Coastguard Worker      * @see ubidi_getProcessedLength
1047*0e209d39SAndroid Build Coastguard Worker      * @see ubidi_orderParagraphsLTR
1048*0e209d39SAndroid Build Coastguard Worker      * \xrefitem stable "Stable" "Stable List" ICU 3.6
1049*0e209d39SAndroid Build Coastguard Worker      */
1050*0e209d39SAndroid Build Coastguard Worker     UBIDI_OPTION_STREAMING = 4
1051*0e209d39SAndroid Build Coastguard Worker } UBiDiReorderingOption;
1052*0e209d39SAndroid Build Coastguard Worker 
1053*0e209d39SAndroid Build Coastguard Worker /**
1054*0e209d39SAndroid Build Coastguard Worker  * Specify which of the reordering options
1055*0e209d39SAndroid Build Coastguard Worker  * should be applied during Bidi transformations.
1056*0e209d39SAndroid Build Coastguard Worker  *
1057*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is a <code>UBiDi</code> object.
1058*0e209d39SAndroid Build Coastguard Worker  * @param reorderingOptions is a combination of zero or more of the following
1059*0e209d39SAndroid Build Coastguard Worker  * options:
1060*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_OPTION_DEFAULT</code>, <code>#UBIDI_OPTION_INSERT_MARKS</code>,
1061*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>, <code>#UBIDI_OPTION_STREAMING</code>.
1062*0e209d39SAndroid Build Coastguard Worker  *
1063*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getReorderingOptions
1064*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
1065*0e209d39SAndroid Build Coastguard Worker  */
1066*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1067*0e209d39SAndroid Build Coastguard Worker ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions) __INTRODUCED_IN(31);
1068*0e209d39SAndroid Build Coastguard Worker 
1069*0e209d39SAndroid Build Coastguard Worker 
1070*0e209d39SAndroid Build Coastguard Worker 
1071*0e209d39SAndroid Build Coastguard Worker /**
1072*0e209d39SAndroid Build Coastguard Worker  * What are the reordering options applied to a given Bidi object?
1073*0e209d39SAndroid Build Coastguard Worker  *
1074*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is a <code>UBiDi</code> object.
1075*0e209d39SAndroid Build Coastguard Worker  * @return the current reordering options of the Bidi object
1076*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setReorderingOptions
1077*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
1078*0e209d39SAndroid Build Coastguard Worker  */
1079*0e209d39SAndroid Build Coastguard Worker U_CAPI uint32_t U_EXPORT2
1080*0e209d39SAndroid Build Coastguard Worker ubidi_getReorderingOptions(UBiDi *pBiDi) __INTRODUCED_IN(31);
1081*0e209d39SAndroid Build Coastguard Worker 
1082*0e209d39SAndroid Build Coastguard Worker 
1083*0e209d39SAndroid Build Coastguard Worker 
1084*0e209d39SAndroid Build Coastguard Worker /**
1085*0e209d39SAndroid Build Coastguard Worker  * Set the context before a call to ubidi_setPara().<p>
1086*0e209d39SAndroid Build Coastguard Worker  *
1087*0e209d39SAndroid Build Coastguard Worker  * ubidi_setPara() computes the left-right directionality for a given piece
1088*0e209d39SAndroid Build Coastguard Worker  * of text which is supplied as one of its arguments. Sometimes this piece
1089*0e209d39SAndroid Build Coastguard Worker  * of text (the "main text") should be considered in context, because text
1090*0e209d39SAndroid Build Coastguard Worker  * appearing before ("prologue") and/or after ("epilogue") the main text
1091*0e209d39SAndroid Build Coastguard Worker  * may affect the result of this computation.<p>
1092*0e209d39SAndroid Build Coastguard Worker  *
1093*0e209d39SAndroid Build Coastguard Worker  * This function specifies the prologue and/or the epilogue for the next
1094*0e209d39SAndroid Build Coastguard Worker  * call to ubidi_setPara(). The characters specified as prologue and
1095*0e209d39SAndroid Build Coastguard Worker  * epilogue should not be modified by the calling program until the call
1096*0e209d39SAndroid Build Coastguard Worker  * to ubidi_setPara() has returned. If successive calls to ubidi_setPara()
1097*0e209d39SAndroid Build Coastguard Worker  * all need specification of a context, ubidi_setContext() must be called
1098*0e209d39SAndroid Build Coastguard Worker  * before each call to ubidi_setPara(). In other words, a context is not
1099*0e209d39SAndroid Build Coastguard Worker  * "remembered" after the following successful call to ubidi_setPara().<p>
1100*0e209d39SAndroid Build Coastguard Worker  *
1101*0e209d39SAndroid Build Coastguard Worker  * If a call to ubidi_setPara() specifies UBIDI_DEFAULT_LTR or
1102*0e209d39SAndroid Build Coastguard Worker  * UBIDI_DEFAULT_RTL as paraLevel and is preceded by a call to
1103*0e209d39SAndroid Build Coastguard Worker  * ubidi_setContext() which specifies a prologue, the paragraph level will
1104*0e209d39SAndroid Build Coastguard Worker  * be computed taking in consideration the text in the prologue.<p>
1105*0e209d39SAndroid Build Coastguard Worker  *
1106*0e209d39SAndroid Build Coastguard Worker  * When ubidi_setPara() is called without a previous call to
1107*0e209d39SAndroid Build Coastguard Worker  * ubidi_setContext, the main text is handled as if preceded and followed
1108*0e209d39SAndroid Build Coastguard Worker  * by strong directional characters at the current paragraph level.
1109*0e209d39SAndroid Build Coastguard Worker  * Calling ubidi_setContext() with specification of a prologue will change
1110*0e209d39SAndroid Build Coastguard Worker  * this behavior by handling the main text as if preceded by the last
1111*0e209d39SAndroid Build Coastguard Worker  * strong character appearing in the prologue, if any.
1112*0e209d39SAndroid Build Coastguard Worker  * Calling ubidi_setContext() with specification of an epilogue will change
1113*0e209d39SAndroid Build Coastguard Worker  * the behavior of ubidi_setPara() by handling the main text as if followed
1114*0e209d39SAndroid Build Coastguard Worker  * by the first strong character or digit appearing in the epilogue, if any.<p>
1115*0e209d39SAndroid Build Coastguard Worker  *
1116*0e209d39SAndroid Build Coastguard Worker  * Note 1: if <code>ubidi_setContext</code> is called repeatedly without
1117*0e209d39SAndroid Build Coastguard Worker  *         calling <code>ubidi_setPara</code>, the earlier calls have no effect,
1118*0e209d39SAndroid Build Coastguard Worker  *         only the last call will be remembered for the next call to
1119*0e209d39SAndroid Build Coastguard Worker  *         <code>ubidi_setPara</code>.<p>
1120*0e209d39SAndroid Build Coastguard Worker  *
1121*0e209d39SAndroid Build Coastguard Worker  * Note 2: calling <code>ubidi_setContext(pBiDi, NULL, 0, NULL, 0, &errorCode)</code>
1122*0e209d39SAndroid Build Coastguard Worker  *         cancels any previous setting of non-empty prologue or epilogue.
1123*0e209d39SAndroid Build Coastguard Worker  *         The next call to <code>ubidi_setPara()</code> will process no
1124*0e209d39SAndroid Build Coastguard Worker  *         prologue or epilogue.<p>
1125*0e209d39SAndroid Build Coastguard Worker  *
1126*0e209d39SAndroid Build Coastguard Worker  * Note 3: users must be aware that even after setting the context
1127*0e209d39SAndroid Build Coastguard Worker  *         before a call to ubidi_setPara() to perform e.g. a logical to visual
1128*0e209d39SAndroid Build Coastguard Worker  *         transformation, the resulting string may not be identical to what it
1129*0e209d39SAndroid Build Coastguard Worker  *         would have been if all the text, including prologue and epilogue, had
1130*0e209d39SAndroid Build Coastguard Worker  *         been processed together.<br>
1131*0e209d39SAndroid Build Coastguard Worker  * Example (upper case letters represent RTL characters):<br>
1132*0e209d39SAndroid Build Coastguard Worker  * &nbsp;&nbsp;prologue = "<code>abc DE</code>"<br>
1133*0e209d39SAndroid Build Coastguard Worker  * &nbsp;&nbsp;epilogue = none<br>
1134*0e209d39SAndroid Build Coastguard Worker  * &nbsp;&nbsp;main text = "<code>FGH xyz</code>"<br>
1135*0e209d39SAndroid Build Coastguard Worker  * &nbsp;&nbsp;paraLevel = UBIDI_LTR<br>
1136*0e209d39SAndroid Build Coastguard Worker  * &nbsp;&nbsp;display without prologue = "<code>HGF xyz</code>"
1137*0e209d39SAndroid Build Coastguard Worker  *             ("HGF" is adjacent to "xyz")<br>
1138*0e209d39SAndroid Build Coastguard Worker  * &nbsp;&nbsp;display with prologue = "<code>abc HGFED xyz</code>"
1139*0e209d39SAndroid Build Coastguard Worker  *             ("HGF" is not adjacent to "xyz")<br>
1140*0e209d39SAndroid Build Coastguard Worker  *
1141*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is a paragraph <code>UBiDi</code> object.
1142*0e209d39SAndroid Build Coastguard Worker  *
1143*0e209d39SAndroid Build Coastguard Worker  * @param prologue is a pointer to the text which precedes the text that
1144*0e209d39SAndroid Build Coastguard Worker  *        will be specified in a coming call to ubidi_setPara().
1145*0e209d39SAndroid Build Coastguard Worker  *        If there is no prologue to consider, then <code>proLength</code>
1146*0e209d39SAndroid Build Coastguard Worker  *        must be zero and this pointer can be NULL.
1147*0e209d39SAndroid Build Coastguard Worker  *
1148*0e209d39SAndroid Build Coastguard Worker  * @param proLength is the length of the prologue; if <code>proLength==-1</code>
1149*0e209d39SAndroid Build Coastguard Worker  *        then the prologue must be zero-terminated.
1150*0e209d39SAndroid Build Coastguard Worker  *        Otherwise proLength must be >= 0. If <code>proLength==0</code>, it means
1151*0e209d39SAndroid Build Coastguard Worker  *        that there is no prologue to consider.
1152*0e209d39SAndroid Build Coastguard Worker  *
1153*0e209d39SAndroid Build Coastguard Worker  * @param epilogue is a pointer to the text which follows the text that
1154*0e209d39SAndroid Build Coastguard Worker  *        will be specified in a coming call to ubidi_setPara().
1155*0e209d39SAndroid Build Coastguard Worker  *        If there is no epilogue to consider, then <code>epiLength</code>
1156*0e209d39SAndroid Build Coastguard Worker  *        must be zero and this pointer can be NULL.
1157*0e209d39SAndroid Build Coastguard Worker  *
1158*0e209d39SAndroid Build Coastguard Worker  * @param epiLength is the length of the epilogue; if <code>epiLength==-1</code>
1159*0e209d39SAndroid Build Coastguard Worker  *        then the epilogue must be zero-terminated.
1160*0e209d39SAndroid Build Coastguard Worker  *        Otherwise epiLength must be >= 0. If <code>epiLength==0</code>, it means
1161*0e209d39SAndroid Build Coastguard Worker  *        that there is no epilogue to consider.
1162*0e209d39SAndroid Build Coastguard Worker  *
1163*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
1164*0e209d39SAndroid Build Coastguard Worker  *
1165*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setPara
1166*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 4.8
1167*0e209d39SAndroid Build Coastguard Worker  */
1168*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1169*0e209d39SAndroid Build Coastguard Worker ubidi_setContext(UBiDi *pBiDi,
1170*0e209d39SAndroid Build Coastguard Worker                  const UChar *prologue, int32_t proLength,
1171*0e209d39SAndroid Build Coastguard Worker                  const UChar *epilogue, int32_t epiLength,
1172*0e209d39SAndroid Build Coastguard Worker                  UErrorCode *pErrorCode) __INTRODUCED_IN(31);
1173*0e209d39SAndroid Build Coastguard Worker 
1174*0e209d39SAndroid Build Coastguard Worker 
1175*0e209d39SAndroid Build Coastguard Worker 
1176*0e209d39SAndroid Build Coastguard Worker /**
1177*0e209d39SAndroid Build Coastguard Worker  * Perform the Unicode Bidi algorithm. It is defined in the
1178*0e209d39SAndroid Build Coastguard Worker  * <a href="http://www.unicode.org/unicode/reports/tr9/">Unicode Standard Annex #9</a>,
1179*0e209d39SAndroid Build Coastguard Worker  * version 13,
1180*0e209d39SAndroid Build Coastguard Worker  * also described in The Unicode Standard, Version 4.0 .<p>
1181*0e209d39SAndroid Build Coastguard Worker  *
1182*0e209d39SAndroid Build Coastguard Worker  * This function takes a piece of plain text containing one or more paragraphs,
1183*0e209d39SAndroid Build Coastguard Worker  * with or without externally specified embedding levels from <i>styled</i>
1184*0e209d39SAndroid Build Coastguard Worker  * text and computes the left-right-directionality of each character.<p>
1185*0e209d39SAndroid Build Coastguard Worker  *
1186*0e209d39SAndroid Build Coastguard Worker  * If the entire text is all of the same directionality, then
1187*0e209d39SAndroid Build Coastguard Worker  * the function may not perform all the steps described by the algorithm,
1188*0e209d39SAndroid Build Coastguard Worker  * i.e., some levels may not be the same as if all steps were performed.
1189*0e209d39SAndroid Build Coastguard Worker  * This is not relevant for unidirectional text.<br>
1190*0e209d39SAndroid Build Coastguard Worker  * For example, in pure LTR text with numbers the numbers would get
1191*0e209d39SAndroid Build Coastguard Worker  * a resolved level of 2 higher than the surrounding text according to
1192*0e209d39SAndroid Build Coastguard Worker  * the algorithm. This implementation may set all resolved levels to
1193*0e209d39SAndroid Build Coastguard Worker  * the same value in such a case.<p>
1194*0e209d39SAndroid Build Coastguard Worker  *
1195*0e209d39SAndroid Build Coastguard Worker  * The text can be composed of multiple paragraphs. Occurrence of a block
1196*0e209d39SAndroid Build Coastguard Worker  * separator in the text terminates a paragraph, and whatever comes next starts
1197*0e209d39SAndroid Build Coastguard Worker  * a new paragraph. The exception to this rule is when a Carriage Return (CR)
1198*0e209d39SAndroid Build Coastguard Worker  * is followed by a Line Feed (LF). Both CR and LF are block separators, but
1199*0e209d39SAndroid Build Coastguard Worker  * in that case, the pair of characters is considered as terminating the
1200*0e209d39SAndroid Build Coastguard Worker  * preceding paragraph, and a new paragraph will be started by a character
1201*0e209d39SAndroid Build Coastguard Worker  * coming after the LF.
1202*0e209d39SAndroid Build Coastguard Worker  *
1203*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi A <code>UBiDi</code> object allocated with <code>ubidi_open()</code>
1204*0e209d39SAndroid Build Coastguard Worker  *        which will be set to contain the reordering information,
1205*0e209d39SAndroid Build Coastguard Worker  *        especially the resolved levels for all the characters in <code>text</code>.
1206*0e209d39SAndroid Build Coastguard Worker  *
1207*0e209d39SAndroid Build Coastguard Worker  * @param text is a pointer to the text that the Bidi algorithm will be performed on.
1208*0e209d39SAndroid Build Coastguard Worker  *        This pointer is stored in the UBiDi object and can be retrieved
1209*0e209d39SAndroid Build Coastguard Worker  *        with <code>ubidi_getText()</code>.<br>
1210*0e209d39SAndroid Build Coastguard Worker  *        <strong>Note:</strong> the text must be (at least) <code>length</code> long.
1211*0e209d39SAndroid Build Coastguard Worker  *
1212*0e209d39SAndroid Build Coastguard Worker  * @param length is the length of the text; if <code>length==-1</code> then
1213*0e209d39SAndroid Build Coastguard Worker  *        the text must be zero-terminated.
1214*0e209d39SAndroid Build Coastguard Worker  *
1215*0e209d39SAndroid Build Coastguard Worker  * @param paraLevel specifies the default level for the text;
1216*0e209d39SAndroid Build Coastguard Worker  *        it is typically 0 (LTR) or 1 (RTL).
1217*0e209d39SAndroid Build Coastguard Worker  *        If the function shall determine the paragraph level from the text,
1218*0e209d39SAndroid Build Coastguard Worker  *        then <code>paraLevel</code> can be set to
1219*0e209d39SAndroid Build Coastguard Worker  *        either <code>#UBIDI_DEFAULT_LTR</code>
1220*0e209d39SAndroid Build Coastguard Worker  *        or <code>#UBIDI_DEFAULT_RTL</code>; if the text contains multiple
1221*0e209d39SAndroid Build Coastguard Worker  *        paragraphs, the paragraph level shall be determined separately for
1222*0e209d39SAndroid Build Coastguard Worker  *        each paragraph; if a paragraph does not include any strongly typed
1223*0e209d39SAndroid Build Coastguard Worker  *        character, then the desired default is used (0 for LTR or 1 for RTL).
1224*0e209d39SAndroid Build Coastguard Worker  *        Any other value between 0 and <code>#UBIDI_MAX_EXPLICIT_LEVEL</code>
1225*0e209d39SAndroid Build Coastguard Worker  *        is also valid, with odd levels indicating RTL.
1226*0e209d39SAndroid Build Coastguard Worker  *
1227*0e209d39SAndroid Build Coastguard Worker  * @param embeddingLevels (in) may be used to preset the embedding and override levels,
1228*0e209d39SAndroid Build Coastguard Worker  *        ignoring characters like LRE and PDF in the text.
1229*0e209d39SAndroid Build Coastguard Worker  *        A level overrides the directional property of its corresponding
1230*0e209d39SAndroid Build Coastguard Worker  *        (same index) character if the level has the
1231*0e209d39SAndroid Build Coastguard Worker  *        <code>#UBIDI_LEVEL_OVERRIDE</code> bit set.<br><br>
1232*0e209d39SAndroid Build Coastguard Worker  *        Aside from that bit, it must be
1233*0e209d39SAndroid Build Coastguard Worker  *        <code>paraLevel<=embeddingLevels[]<=UBIDI_MAX_EXPLICIT_LEVEL</code>,
1234*0e209d39SAndroid Build Coastguard Worker  *        except that level 0 is always allowed.
1235*0e209d39SAndroid Build Coastguard Worker  *        Level 0 for a paragraph separator prevents reordering of paragraphs;
1236*0e209d39SAndroid Build Coastguard Worker  *        this only works reliably if <code>#UBIDI_LEVEL_OVERRIDE</code>
1237*0e209d39SAndroid Build Coastguard Worker  *        is also set for paragraph separators.
1238*0e209d39SAndroid Build Coastguard Worker  *        Level 0 for other characters is treated as a wildcard
1239*0e209d39SAndroid Build Coastguard Worker  *        and is lifted up to the resolved level of the surrounding paragraph.<br><br>
1240*0e209d39SAndroid Build Coastguard Worker  *        <strong>Caution: </strong>A copy of this pointer, not of the levels,
1241*0e209d39SAndroid Build Coastguard Worker  *        will be stored in the <code>UBiDi</code> object;
1242*0e209d39SAndroid Build Coastguard Worker  *        the <code>embeddingLevels</code> array must not be
1243*0e209d39SAndroid Build Coastguard Worker  *        deallocated before the <code>UBiDi</code> structure is destroyed or reused,
1244*0e209d39SAndroid Build Coastguard Worker  *        and the <code>embeddingLevels</code>
1245*0e209d39SAndroid Build Coastguard Worker  *        should not be modified to avoid unexpected results on subsequent Bidi operations.
1246*0e209d39SAndroid Build Coastguard Worker  *        However, the <code>ubidi_setPara()</code> and
1247*0e209d39SAndroid Build Coastguard Worker  *        <code>ubidi_setLine()</code> functions may modify some or all of the levels.<br><br>
1248*0e209d39SAndroid Build Coastguard Worker  *        After the <code>UBiDi</code> object is reused or destroyed, the caller
1249*0e209d39SAndroid Build Coastguard Worker  *        must take care of the deallocation of the <code>embeddingLevels</code> array.<br><br>
1250*0e209d39SAndroid Build Coastguard Worker  *        <strong>Note:</strong> the <code>embeddingLevels</code> array must be
1251*0e209d39SAndroid Build Coastguard Worker  *        at least <code>length</code> long.
1252*0e209d39SAndroid Build Coastguard Worker  *        This pointer can be <code>NULL</code> if this
1253*0e209d39SAndroid Build Coastguard Worker  *        value is not necessary.
1254*0e209d39SAndroid Build Coastguard Worker  *
1255*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
1256*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1257*0e209d39SAndroid Build Coastguard Worker  */
1258*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1259*0e209d39SAndroid Build Coastguard Worker ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
1260*0e209d39SAndroid Build Coastguard Worker               UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
1261*0e209d39SAndroid Build Coastguard Worker               UErrorCode *pErrorCode) __INTRODUCED_IN(31);
1262*0e209d39SAndroid Build Coastguard Worker 
1263*0e209d39SAndroid Build Coastguard Worker 
1264*0e209d39SAndroid Build Coastguard Worker 
1265*0e209d39SAndroid Build Coastguard Worker /**
1266*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setLine()</code> sets a <code>UBiDi</code> to
1267*0e209d39SAndroid Build Coastguard Worker  * contain the reordering information, especially the resolved levels,
1268*0e209d39SAndroid Build Coastguard Worker  * for all the characters in a line of text. This line of text is
1269*0e209d39SAndroid Build Coastguard Worker  * specified by referring to a <code>UBiDi</code> object representing
1270*0e209d39SAndroid Build Coastguard Worker  * this information for a piece of text containing one or more paragraphs,
1271*0e209d39SAndroid Build Coastguard Worker  * and by specifying a range of indexes in this text.<p>
1272*0e209d39SAndroid Build Coastguard Worker  * In the new line object, the indexes will range from 0 to <code>limit-start-1</code>.<p>
1273*0e209d39SAndroid Build Coastguard Worker  *
1274*0e209d39SAndroid Build Coastguard Worker  * This is used after calling <code>ubidi_setPara()</code>
1275*0e209d39SAndroid Build Coastguard Worker  * for a piece of text, and after line-breaking on that text.
1276*0e209d39SAndroid Build Coastguard Worker  * It is not necessary if each paragraph is treated as a single line.<p>
1277*0e209d39SAndroid Build Coastguard Worker  *
1278*0e209d39SAndroid Build Coastguard Worker  * After line-breaking, rules (L1) and (L2) for the treatment of
1279*0e209d39SAndroid Build Coastguard Worker  * trailing WS and for reordering are performed on
1280*0e209d39SAndroid Build Coastguard Worker  * a <code>UBiDi</code> object that represents a line.<p>
1281*0e209d39SAndroid Build Coastguard Worker  *
1282*0e209d39SAndroid Build Coastguard Worker  * <strong>Important: </strong><code>pLineBiDi</code> shares data with
1283*0e209d39SAndroid Build Coastguard Worker  * <code>pParaBiDi</code>.
1284*0e209d39SAndroid Build Coastguard Worker  * You must destroy or reuse <code>pLineBiDi</code> before <code>pParaBiDi</code>.
1285*0e209d39SAndroid Build Coastguard Worker  * In other words, you must destroy or reuse the <code>UBiDi</code> object for a line
1286*0e209d39SAndroid Build Coastguard Worker  * before the object for its parent paragraph.<p>
1287*0e209d39SAndroid Build Coastguard Worker  *
1288*0e209d39SAndroid Build Coastguard Worker  * The text pointer that was stored in <code>pParaBiDi</code> is also copied,
1289*0e209d39SAndroid Build Coastguard Worker  * and <code>start</code> is added to it so that it points to the beginning of the
1290*0e209d39SAndroid Build Coastguard Worker  * line for this object.
1291*0e209d39SAndroid Build Coastguard Worker  *
1292*0e209d39SAndroid Build Coastguard Worker  * @param pParaBiDi is the parent paragraph object. It must have been set
1293*0e209d39SAndroid Build Coastguard Worker  * by a successful call to ubidi_setPara.
1294*0e209d39SAndroid Build Coastguard Worker  *
1295*0e209d39SAndroid Build Coastguard Worker  * @param start is the line's first index into the text.
1296*0e209d39SAndroid Build Coastguard Worker  *
1297*0e209d39SAndroid Build Coastguard Worker  * @param limit is just behind the line's last index into the text
1298*0e209d39SAndroid Build Coastguard Worker  *        (its last index +1).<br>
1299*0e209d39SAndroid Build Coastguard Worker  *        It must be <code>0<=start<limit<=</code>containing paragraph limit.
1300*0e209d39SAndroid Build Coastguard Worker  *        If the specified line crosses a paragraph boundary, the function
1301*0e209d39SAndroid Build Coastguard Worker  *        will terminate with error code U_ILLEGAL_ARGUMENT_ERROR.
1302*0e209d39SAndroid Build Coastguard Worker  *
1303*0e209d39SAndroid Build Coastguard Worker  * @param pLineBiDi is the object that will now represent a line of the text.
1304*0e209d39SAndroid Build Coastguard Worker  *
1305*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
1306*0e209d39SAndroid Build Coastguard Worker  *
1307*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setPara
1308*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getProcessedLength
1309*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1310*0e209d39SAndroid Build Coastguard Worker  */
1311*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1312*0e209d39SAndroid Build Coastguard Worker ubidi_setLine(const UBiDi *pParaBiDi,
1313*0e209d39SAndroid Build Coastguard Worker               int32_t start, int32_t limit,
1314*0e209d39SAndroid Build Coastguard Worker               UBiDi *pLineBiDi,
1315*0e209d39SAndroid Build Coastguard Worker               UErrorCode *pErrorCode) __INTRODUCED_IN(31);
1316*0e209d39SAndroid Build Coastguard Worker 
1317*0e209d39SAndroid Build Coastguard Worker 
1318*0e209d39SAndroid Build Coastguard Worker 
1319*0e209d39SAndroid Build Coastguard Worker /**
1320*0e209d39SAndroid Build Coastguard Worker  * Get the directionality of the text.
1321*0e209d39SAndroid Build Coastguard Worker  *
1322*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1323*0e209d39SAndroid Build Coastguard Worker  *
1324*0e209d39SAndroid Build Coastguard Worker  * @return a value of <code>UBIDI_LTR</code>, <code>UBIDI_RTL</code>
1325*0e209d39SAndroid Build Coastguard Worker  *         or <code>UBIDI_MIXED</code>
1326*0e209d39SAndroid Build Coastguard Worker  *         that indicates if the entire text
1327*0e209d39SAndroid Build Coastguard Worker  *         represented by this object is unidirectional,
1328*0e209d39SAndroid Build Coastguard Worker  *         and which direction, or if it is mixed-directional.
1329*0e209d39SAndroid Build Coastguard Worker  * Note -  The value <code>UBIDI_NEUTRAL</code> is never returned from this method.
1330*0e209d39SAndroid Build Coastguard Worker  *
1331*0e209d39SAndroid Build Coastguard Worker  * @see UBiDiDirection
1332*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1333*0e209d39SAndroid Build Coastguard Worker  */
1334*0e209d39SAndroid Build Coastguard Worker U_CAPI UBiDiDirection U_EXPORT2
1335*0e209d39SAndroid Build Coastguard Worker ubidi_getDirection(const UBiDi *pBiDi) __INTRODUCED_IN(31);
1336*0e209d39SAndroid Build Coastguard Worker 
1337*0e209d39SAndroid Build Coastguard Worker 
1338*0e209d39SAndroid Build Coastguard Worker 
1339*0e209d39SAndroid Build Coastguard Worker /**
1340*0e209d39SAndroid Build Coastguard Worker  * Gets the base direction of the text provided according
1341*0e209d39SAndroid Build Coastguard Worker  * to the Unicode Bidirectional Algorithm. The base direction
1342*0e209d39SAndroid Build Coastguard Worker  * is derived from the first character in the string with bidirectional
1343*0e209d39SAndroid Build Coastguard Worker  * character type L, R, or AL. If the first such character has type L,
1344*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_LTR</code> is returned. If the first such character has
1345*0e209d39SAndroid Build Coastguard Worker  * type R or AL, <code>UBIDI_RTL</code> is returned. If the string does
1346*0e209d39SAndroid Build Coastguard Worker  * not contain any character of these types, then
1347*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_NEUTRAL</code> is returned.
1348*0e209d39SAndroid Build Coastguard Worker  *
1349*0e209d39SAndroid Build Coastguard Worker  * This is a lightweight function for use when only the base direction
1350*0e209d39SAndroid Build Coastguard Worker  * is needed and no further bidi processing of the text is needed.
1351*0e209d39SAndroid Build Coastguard Worker  *
1352*0e209d39SAndroid Build Coastguard Worker  * @param text is a pointer to the text whose base
1353*0e209d39SAndroid Build Coastguard Worker  *             direction is needed.
1354*0e209d39SAndroid Build Coastguard Worker  * Note: the text must be (at least) @c length long.
1355*0e209d39SAndroid Build Coastguard Worker  *
1356*0e209d39SAndroid Build Coastguard Worker  * @param length is the length of the text;
1357*0e209d39SAndroid Build Coastguard Worker  *               if <code>length==-1</code> then the text
1358*0e209d39SAndroid Build Coastguard Worker  *               must be zero-terminated.
1359*0e209d39SAndroid Build Coastguard Worker  *
1360*0e209d39SAndroid Build Coastguard Worker  * @return  <code>UBIDI_LTR</code>, <code>UBIDI_RTL</code>,
1361*0e209d39SAndroid Build Coastguard Worker  *          <code>UBIDI_NEUTRAL</code>
1362*0e209d39SAndroid Build Coastguard Worker  *
1363*0e209d39SAndroid Build Coastguard Worker  * @see UBiDiDirection
1364*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 4.6
1365*0e209d39SAndroid Build Coastguard Worker  */
1366*0e209d39SAndroid Build Coastguard Worker U_CAPI UBiDiDirection U_EXPORT2
1367*0e209d39SAndroid Build Coastguard Worker ubidi_getBaseDirection(const UChar *text,  int32_t length ) __INTRODUCED_IN(31);
1368*0e209d39SAndroid Build Coastguard Worker 
1369*0e209d39SAndroid Build Coastguard Worker 
1370*0e209d39SAndroid Build Coastguard Worker 
1371*0e209d39SAndroid Build Coastguard Worker /**
1372*0e209d39SAndroid Build Coastguard Worker  * Get the pointer to the text.
1373*0e209d39SAndroid Build Coastguard Worker  *
1374*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1375*0e209d39SAndroid Build Coastguard Worker  *
1376*0e209d39SAndroid Build Coastguard Worker  * @return The pointer to the text that the UBiDi object was created for.
1377*0e209d39SAndroid Build Coastguard Worker  *
1378*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setPara
1379*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setLine
1380*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1381*0e209d39SAndroid Build Coastguard Worker  */
1382*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar * U_EXPORT2
1383*0e209d39SAndroid Build Coastguard Worker ubidi_getText(const UBiDi *pBiDi) __INTRODUCED_IN(31);
1384*0e209d39SAndroid Build Coastguard Worker 
1385*0e209d39SAndroid Build Coastguard Worker 
1386*0e209d39SAndroid Build Coastguard Worker 
1387*0e209d39SAndroid Build Coastguard Worker /**
1388*0e209d39SAndroid Build Coastguard Worker  * Get the length of the text.
1389*0e209d39SAndroid Build Coastguard Worker  *
1390*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1391*0e209d39SAndroid Build Coastguard Worker  *
1392*0e209d39SAndroid Build Coastguard Worker  * @return The length of the text that the UBiDi object was created for.
1393*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1394*0e209d39SAndroid Build Coastguard Worker  */
1395*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1396*0e209d39SAndroid Build Coastguard Worker ubidi_getLength(const UBiDi *pBiDi) __INTRODUCED_IN(31);
1397*0e209d39SAndroid Build Coastguard Worker 
1398*0e209d39SAndroid Build Coastguard Worker 
1399*0e209d39SAndroid Build Coastguard Worker 
1400*0e209d39SAndroid Build Coastguard Worker /**
1401*0e209d39SAndroid Build Coastguard Worker  * Get the paragraph level of the text.
1402*0e209d39SAndroid Build Coastguard Worker  *
1403*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1404*0e209d39SAndroid Build Coastguard Worker  *
1405*0e209d39SAndroid Build Coastguard Worker  * @return The paragraph level. If there are multiple paragraphs, their
1406*0e209d39SAndroid Build Coastguard Worker  *         level may vary if the required paraLevel is UBIDI_DEFAULT_LTR or
1407*0e209d39SAndroid Build Coastguard Worker  *         UBIDI_DEFAULT_RTL.  In that case, the level of the first paragraph
1408*0e209d39SAndroid Build Coastguard Worker  *         is returned.
1409*0e209d39SAndroid Build Coastguard Worker  *
1410*0e209d39SAndroid Build Coastguard Worker  * @see UBiDiLevel
1411*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getParagraph
1412*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getParagraphByIndex
1413*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1414*0e209d39SAndroid Build Coastguard Worker  */
1415*0e209d39SAndroid Build Coastguard Worker U_CAPI UBiDiLevel U_EXPORT2
1416*0e209d39SAndroid Build Coastguard Worker ubidi_getParaLevel(const UBiDi *pBiDi) __INTRODUCED_IN(31);
1417*0e209d39SAndroid Build Coastguard Worker 
1418*0e209d39SAndroid Build Coastguard Worker 
1419*0e209d39SAndroid Build Coastguard Worker 
1420*0e209d39SAndroid Build Coastguard Worker /**
1421*0e209d39SAndroid Build Coastguard Worker  * Get the number of paragraphs.
1422*0e209d39SAndroid Build Coastguard Worker  *
1423*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1424*0e209d39SAndroid Build Coastguard Worker  *
1425*0e209d39SAndroid Build Coastguard Worker  * @return The number of paragraphs.
1426*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.4
1427*0e209d39SAndroid Build Coastguard Worker  */
1428*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1429*0e209d39SAndroid Build Coastguard Worker ubidi_countParagraphs(UBiDi *pBiDi) __INTRODUCED_IN(31);
1430*0e209d39SAndroid Build Coastguard Worker 
1431*0e209d39SAndroid Build Coastguard Worker 
1432*0e209d39SAndroid Build Coastguard Worker 
1433*0e209d39SAndroid Build Coastguard Worker /**
1434*0e209d39SAndroid Build Coastguard Worker  * Get a paragraph, given a position within the text.
1435*0e209d39SAndroid Build Coastguard Worker  * This function returns information about a paragraph.<br>
1436*0e209d39SAndroid Build Coastguard Worker  * Note: if the paragraph index is known, it is more efficient to
1437*0e209d39SAndroid Build Coastguard Worker  * retrieve the paragraph information using ubidi_getParagraphByIndex().<p>
1438*0e209d39SAndroid Build Coastguard Worker  *
1439*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1440*0e209d39SAndroid Build Coastguard Worker  *
1441*0e209d39SAndroid Build Coastguard Worker  * @param charIndex is the index of a character within the text, in the
1442*0e209d39SAndroid Build Coastguard Worker  *        range <code>[0..ubidi_getProcessedLength(pBiDi)-1]</code>.
1443*0e209d39SAndroid Build Coastguard Worker  *
1444*0e209d39SAndroid Build Coastguard Worker  * @param pParaStart will receive the index of the first character of the
1445*0e209d39SAndroid Build Coastguard Worker  *        paragraph in the text.
1446*0e209d39SAndroid Build Coastguard Worker  *        This pointer can be <code>NULL</code> if this
1447*0e209d39SAndroid Build Coastguard Worker  *        value is not necessary.
1448*0e209d39SAndroid Build Coastguard Worker  *
1449*0e209d39SAndroid Build Coastguard Worker  * @param pParaLimit will receive the limit of the paragraph.
1450*0e209d39SAndroid Build Coastguard Worker  *        The l-value that you point to here may be the
1451*0e209d39SAndroid Build Coastguard Worker  *        same expression (variable) as the one for
1452*0e209d39SAndroid Build Coastguard Worker  *        <code>charIndex</code>.
1453*0e209d39SAndroid Build Coastguard Worker  *        This pointer can be <code>NULL</code> if this
1454*0e209d39SAndroid Build Coastguard Worker  *        value is not necessary.
1455*0e209d39SAndroid Build Coastguard Worker  *
1456*0e209d39SAndroid Build Coastguard Worker  * @param pParaLevel will receive the level of the paragraph.
1457*0e209d39SAndroid Build Coastguard Worker  *        This pointer can be <code>NULL</code> if this
1458*0e209d39SAndroid Build Coastguard Worker  *        value is not necessary.
1459*0e209d39SAndroid Build Coastguard Worker  *
1460*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
1461*0e209d39SAndroid Build Coastguard Worker  *
1462*0e209d39SAndroid Build Coastguard Worker  * @return The index of the paragraph containing the specified position.
1463*0e209d39SAndroid Build Coastguard Worker  *
1464*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getProcessedLength
1465*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.4
1466*0e209d39SAndroid Build Coastguard Worker  */
1467*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1468*0e209d39SAndroid Build Coastguard Worker ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
1469*0e209d39SAndroid Build Coastguard Worker                    int32_t *pParaLimit, UBiDiLevel *pParaLevel,
1470*0e209d39SAndroid Build Coastguard Worker                    UErrorCode *pErrorCode) __INTRODUCED_IN(31);
1471*0e209d39SAndroid Build Coastguard Worker 
1472*0e209d39SAndroid Build Coastguard Worker 
1473*0e209d39SAndroid Build Coastguard Worker 
1474*0e209d39SAndroid Build Coastguard Worker /**
1475*0e209d39SAndroid Build Coastguard Worker  * Get a paragraph, given the index of this paragraph.
1476*0e209d39SAndroid Build Coastguard Worker  *
1477*0e209d39SAndroid Build Coastguard Worker  * This function returns information about a paragraph.<p>
1478*0e209d39SAndroid Build Coastguard Worker  *
1479*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph <code>UBiDi</code> object.
1480*0e209d39SAndroid Build Coastguard Worker  *
1481*0e209d39SAndroid Build Coastguard Worker  * @param paraIndex is the number of the paragraph, in the
1482*0e209d39SAndroid Build Coastguard Worker  *        range <code>[0..ubidi_countParagraphs(pBiDi)-1]</code>.
1483*0e209d39SAndroid Build Coastguard Worker  *
1484*0e209d39SAndroid Build Coastguard Worker  * @param pParaStart will receive the index of the first character of the
1485*0e209d39SAndroid Build Coastguard Worker  *        paragraph in the text.
1486*0e209d39SAndroid Build Coastguard Worker  *        This pointer can be <code>NULL</code> if this
1487*0e209d39SAndroid Build Coastguard Worker  *        value is not necessary.
1488*0e209d39SAndroid Build Coastguard Worker  *
1489*0e209d39SAndroid Build Coastguard Worker  * @param pParaLimit will receive the limit of the paragraph.
1490*0e209d39SAndroid Build Coastguard Worker  *        This pointer can be <code>NULL</code> if this
1491*0e209d39SAndroid Build Coastguard Worker  *        value is not necessary.
1492*0e209d39SAndroid Build Coastguard Worker  *
1493*0e209d39SAndroid Build Coastguard Worker  * @param pParaLevel will receive the level of the paragraph.
1494*0e209d39SAndroid Build Coastguard Worker  *        This pointer can be <code>NULL</code> if this
1495*0e209d39SAndroid Build Coastguard Worker  *        value is not necessary.
1496*0e209d39SAndroid Build Coastguard Worker  *
1497*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
1498*0e209d39SAndroid Build Coastguard Worker  *
1499*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.4
1500*0e209d39SAndroid Build Coastguard Worker  */
1501*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1502*0e209d39SAndroid Build Coastguard Worker ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
1503*0e209d39SAndroid Build Coastguard Worker                           int32_t *pParaStart, int32_t *pParaLimit,
1504*0e209d39SAndroid Build Coastguard Worker                           UBiDiLevel *pParaLevel, UErrorCode *pErrorCode) __INTRODUCED_IN(31);
1505*0e209d39SAndroid Build Coastguard Worker 
1506*0e209d39SAndroid Build Coastguard Worker 
1507*0e209d39SAndroid Build Coastguard Worker 
1508*0e209d39SAndroid Build Coastguard Worker /**
1509*0e209d39SAndroid Build Coastguard Worker  * Get the level for one character.
1510*0e209d39SAndroid Build Coastguard Worker  *
1511*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1512*0e209d39SAndroid Build Coastguard Worker  *
1513*0e209d39SAndroid Build Coastguard Worker  * @param charIndex the index of a character. It must be in the range
1514*0e209d39SAndroid Build Coastguard Worker  *         [0..ubidi_getProcessedLength(pBiDi)].
1515*0e209d39SAndroid Build Coastguard Worker  *
1516*0e209d39SAndroid Build Coastguard Worker  * @return The level for the character at charIndex (0 if charIndex is not
1517*0e209d39SAndroid Build Coastguard Worker  *         in the valid range).
1518*0e209d39SAndroid Build Coastguard Worker  *
1519*0e209d39SAndroid Build Coastguard Worker  * @see UBiDiLevel
1520*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getProcessedLength
1521*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1522*0e209d39SAndroid Build Coastguard Worker  */
1523*0e209d39SAndroid Build Coastguard Worker U_CAPI UBiDiLevel U_EXPORT2
1524*0e209d39SAndroid Build Coastguard Worker ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex) __INTRODUCED_IN(31);
1525*0e209d39SAndroid Build Coastguard Worker 
1526*0e209d39SAndroid Build Coastguard Worker 
1527*0e209d39SAndroid Build Coastguard Worker 
1528*0e209d39SAndroid Build Coastguard Worker /**
1529*0e209d39SAndroid Build Coastguard Worker  * Get an array of levels for each character.<p>
1530*0e209d39SAndroid Build Coastguard Worker  *
1531*0e209d39SAndroid Build Coastguard Worker  * Note that this function may allocate memory under some
1532*0e209d39SAndroid Build Coastguard Worker  * circumstances, unlike <code>ubidi_getLevelAt()</code>.
1533*0e209d39SAndroid Build Coastguard Worker  *
1534*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object, whose
1535*0e209d39SAndroid Build Coastguard Worker  *        text length must be strictly positive.
1536*0e209d39SAndroid Build Coastguard Worker  *
1537*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
1538*0e209d39SAndroid Build Coastguard Worker  *
1539*0e209d39SAndroid Build Coastguard Worker  * @return The levels array for the text,
1540*0e209d39SAndroid Build Coastguard Worker  *         or <code>NULL</code> if an error occurs.
1541*0e209d39SAndroid Build Coastguard Worker  *
1542*0e209d39SAndroid Build Coastguard Worker  * @see UBiDiLevel
1543*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getProcessedLength
1544*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1545*0e209d39SAndroid Build Coastguard Worker  */
1546*0e209d39SAndroid Build Coastguard Worker U_CAPI const UBiDiLevel * U_EXPORT2
1547*0e209d39SAndroid Build Coastguard Worker ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode) __INTRODUCED_IN(31);
1548*0e209d39SAndroid Build Coastguard Worker 
1549*0e209d39SAndroid Build Coastguard Worker 
1550*0e209d39SAndroid Build Coastguard Worker 
1551*0e209d39SAndroid Build Coastguard Worker /**
1552*0e209d39SAndroid Build Coastguard Worker  * Get a logical run.
1553*0e209d39SAndroid Build Coastguard Worker  * This function returns information about a run and is used
1554*0e209d39SAndroid Build Coastguard Worker  * to retrieve runs in logical order.<p>
1555*0e209d39SAndroid Build Coastguard Worker  * This is especially useful for line-breaking on a paragraph.
1556*0e209d39SAndroid Build Coastguard Worker  *
1557*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1558*0e209d39SAndroid Build Coastguard Worker  *
1559*0e209d39SAndroid Build Coastguard Worker  * @param logicalPosition is a logical position within the source text.
1560*0e209d39SAndroid Build Coastguard Worker  *
1561*0e209d39SAndroid Build Coastguard Worker  * @param pLogicalLimit will receive the limit of the corresponding run.
1562*0e209d39SAndroid Build Coastguard Worker  *        The l-value that you point to here may be the
1563*0e209d39SAndroid Build Coastguard Worker  *        same expression (variable) as the one for
1564*0e209d39SAndroid Build Coastguard Worker  *        <code>logicalPosition</code>.
1565*0e209d39SAndroid Build Coastguard Worker  *        This pointer can be <code>NULL</code> if this
1566*0e209d39SAndroid Build Coastguard Worker  *        value is not necessary.
1567*0e209d39SAndroid Build Coastguard Worker  *
1568*0e209d39SAndroid Build Coastguard Worker  * @param pLevel will receive the level of the corresponding run.
1569*0e209d39SAndroid Build Coastguard Worker  *        This pointer can be <code>NULL</code> if this
1570*0e209d39SAndroid Build Coastguard Worker  *        value is not necessary.
1571*0e209d39SAndroid Build Coastguard Worker  *
1572*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getProcessedLength
1573*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1574*0e209d39SAndroid Build Coastguard Worker  */
1575*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1576*0e209d39SAndroid Build Coastguard Worker ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
1577*0e209d39SAndroid Build Coastguard Worker                     int32_t *pLogicalLimit, UBiDiLevel *pLevel) __INTRODUCED_IN(31);
1578*0e209d39SAndroid Build Coastguard Worker 
1579*0e209d39SAndroid Build Coastguard Worker 
1580*0e209d39SAndroid Build Coastguard Worker 
1581*0e209d39SAndroid Build Coastguard Worker /**
1582*0e209d39SAndroid Build Coastguard Worker  * Get the number of runs.
1583*0e209d39SAndroid Build Coastguard Worker  * This function may invoke the actual reordering on the
1584*0e209d39SAndroid Build Coastguard Worker  * <code>UBiDi</code> object, after <code>ubidi_setPara()</code>
1585*0e209d39SAndroid Build Coastguard Worker  * may have resolved only the levels of the text. Therefore,
1586*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_countRuns()</code> may have to allocate memory,
1587*0e209d39SAndroid Build Coastguard Worker  * and may fail doing so.
1588*0e209d39SAndroid Build Coastguard Worker  *
1589*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1590*0e209d39SAndroid Build Coastguard Worker  *
1591*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
1592*0e209d39SAndroid Build Coastguard Worker  *
1593*0e209d39SAndroid Build Coastguard Worker  * @return The number of runs.
1594*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1595*0e209d39SAndroid Build Coastguard Worker  */
1596*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1597*0e209d39SAndroid Build Coastguard Worker ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode) __INTRODUCED_IN(31);
1598*0e209d39SAndroid Build Coastguard Worker 
1599*0e209d39SAndroid Build Coastguard Worker 
1600*0e209d39SAndroid Build Coastguard Worker 
1601*0e209d39SAndroid Build Coastguard Worker /**
1602*0e209d39SAndroid Build Coastguard Worker  * Get one run's logical start, length, and directionality,
1603*0e209d39SAndroid Build Coastguard Worker  * which can be 0 for LTR or 1 for RTL.
1604*0e209d39SAndroid Build Coastguard Worker  * In an RTL run, the character at the logical start is
1605*0e209d39SAndroid Build Coastguard Worker  * visually on the right of the displayed run.
1606*0e209d39SAndroid Build Coastguard Worker  * The length is the number of characters in the run.<p>
1607*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_countRuns()</code> should be called
1608*0e209d39SAndroid Build Coastguard Worker  * before the runs are retrieved.
1609*0e209d39SAndroid Build Coastguard Worker  *
1610*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1611*0e209d39SAndroid Build Coastguard Worker  *
1612*0e209d39SAndroid Build Coastguard Worker  * @param runIndex is the number of the run in visual order, in the
1613*0e209d39SAndroid Build Coastguard Worker  *        range <code>[0..ubidi_countRuns(pBiDi)-1]</code>.
1614*0e209d39SAndroid Build Coastguard Worker  *
1615*0e209d39SAndroid Build Coastguard Worker  * @param pLogicalStart is the first logical character index in the text.
1616*0e209d39SAndroid Build Coastguard Worker  *        The pointer may be <code>NULL</code> if this index is not needed.
1617*0e209d39SAndroid Build Coastguard Worker  *
1618*0e209d39SAndroid Build Coastguard Worker  * @param pLength is the number of characters (at least one) in the run.
1619*0e209d39SAndroid Build Coastguard Worker  *        The pointer may be <code>NULL</code> if this is not needed.
1620*0e209d39SAndroid Build Coastguard Worker  *
1621*0e209d39SAndroid Build Coastguard Worker  * @return the directionality of the run,
1622*0e209d39SAndroid Build Coastguard Worker  *         <code>UBIDI_LTR==0</code> or <code>UBIDI_RTL==1</code>,
1623*0e209d39SAndroid Build Coastguard Worker  *         never <code>UBIDI_MIXED</code>,
1624*0e209d39SAndroid Build Coastguard Worker  *         never <code>UBIDI_NEUTRAL</code>.
1625*0e209d39SAndroid Build Coastguard Worker  *
1626*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_countRuns
1627*0e209d39SAndroid Build Coastguard Worker  *
1628*0e209d39SAndroid Build Coastguard Worker  * Example:
1629*0e209d39SAndroid Build Coastguard Worker  * <pre>
1630*0e209d39SAndroid Build Coastguard Worker  * \code
1631*0e209d39SAndroid Build Coastguard Worker  * int32_t i, count=ubidi_countRuns(pBiDi),
1632*0e209d39SAndroid Build Coastguard Worker  *         logicalStart, visualIndex=0, length;
1633*0e209d39SAndroid Build Coastguard Worker  * for(i=0; i<count; ++i) {
1634*0e209d39SAndroid Build Coastguard Worker  *    if(UBIDI_LTR==ubidi_getVisualRun(pBiDi, i, &logicalStart, &length)) {
1635*0e209d39SAndroid Build Coastguard Worker  *         do { // LTR
1636*0e209d39SAndroid Build Coastguard Worker  *             show_char(text[logicalStart++], visualIndex++);
1637*0e209d39SAndroid Build Coastguard Worker  *         } while(--length>0);
1638*0e209d39SAndroid Build Coastguard Worker  *     } else {
1639*0e209d39SAndroid Build Coastguard Worker  *         logicalStart+=length;  // logicalLimit
1640*0e209d39SAndroid Build Coastguard Worker  *         do { // RTL
1641*0e209d39SAndroid Build Coastguard Worker  *             show_char(text[--logicalStart], visualIndex++);
1642*0e209d39SAndroid Build Coastguard Worker  *         } while(--length>0);
1643*0e209d39SAndroid Build Coastguard Worker  *     }
1644*0e209d39SAndroid Build Coastguard Worker  * }
1645*0e209d39SAndroid Build Coastguard Worker  *\endcode
1646*0e209d39SAndroid Build Coastguard Worker  * </pre>
1647*0e209d39SAndroid Build Coastguard Worker  *
1648*0e209d39SAndroid Build Coastguard Worker  * Note that in right-to-left runs, code like this places
1649*0e209d39SAndroid Build Coastguard Worker  * second surrogates before first ones (which is generally a bad idea)
1650*0e209d39SAndroid Build Coastguard Worker  * and combining characters before base characters.
1651*0e209d39SAndroid Build Coastguard Worker  * <p>
1652*0e209d39SAndroid Build Coastguard Worker  * Use of <code>ubidi_writeReordered()</code>, optionally with the
1653*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_KEEP_BASE_COMBINING</code> option, can be considered in order
1654*0e209d39SAndroid Build Coastguard Worker  * to avoid these issues.
1655*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1656*0e209d39SAndroid Build Coastguard Worker  */
1657*0e209d39SAndroid Build Coastguard Worker U_CAPI UBiDiDirection U_EXPORT2
1658*0e209d39SAndroid Build Coastguard Worker ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
1659*0e209d39SAndroid Build Coastguard Worker                    int32_t *pLogicalStart, int32_t *pLength) __INTRODUCED_IN(31);
1660*0e209d39SAndroid Build Coastguard Worker 
1661*0e209d39SAndroid Build Coastguard Worker 
1662*0e209d39SAndroid Build Coastguard Worker 
1663*0e209d39SAndroid Build Coastguard Worker /**
1664*0e209d39SAndroid Build Coastguard Worker  * Get the visual position from a logical text position.
1665*0e209d39SAndroid Build Coastguard Worker  * If such a mapping is used many times on the same
1666*0e209d39SAndroid Build Coastguard Worker  * <code>UBiDi</code> object, then calling
1667*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_getLogicalMap()</code> is more efficient.<p>
1668*0e209d39SAndroid Build Coastguard Worker  *
1669*0e209d39SAndroid Build Coastguard Worker  * The value returned may be <code>#UBIDI_MAP_NOWHERE</code> if there is no
1670*0e209d39SAndroid Build Coastguard Worker  * visual position because the corresponding text character is a Bidi control
1671*0e209d39SAndroid Build Coastguard Worker  * removed from output by the option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>.
1672*0e209d39SAndroid Build Coastguard Worker  * <p>
1673*0e209d39SAndroid Build Coastguard Worker  * When the visual output is altered by using options of
1674*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,
1675*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,
1676*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the visual position returned may not
1677*0e209d39SAndroid Build Coastguard Worker  * be correct. It is advised to use, when possible, reordering options
1678*0e209d39SAndroid Build Coastguard Worker  * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.
1679*0e209d39SAndroid Build Coastguard Worker  * <p>
1680*0e209d39SAndroid Build Coastguard Worker  * Note that in right-to-left runs, this mapping places
1681*0e209d39SAndroid Build Coastguard Worker  * second surrogates before first ones (which is generally a bad idea)
1682*0e209d39SAndroid Build Coastguard Worker  * and combining characters before base characters.
1683*0e209d39SAndroid Build Coastguard Worker  * Use of <code>ubidi_writeReordered()</code>, optionally with the
1684*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_KEEP_BASE_COMBINING</code> option can be considered instead
1685*0e209d39SAndroid Build Coastguard Worker  * of using the mapping, in order to avoid these issues.
1686*0e209d39SAndroid Build Coastguard Worker  *
1687*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1688*0e209d39SAndroid Build Coastguard Worker  *
1689*0e209d39SAndroid Build Coastguard Worker  * @param logicalIndex is the index of a character in the text.
1690*0e209d39SAndroid Build Coastguard Worker  *
1691*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
1692*0e209d39SAndroid Build Coastguard Worker  *
1693*0e209d39SAndroid Build Coastguard Worker  * @return The visual position of this character.
1694*0e209d39SAndroid Build Coastguard Worker  *
1695*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getLogicalMap
1696*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getLogicalIndex
1697*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getProcessedLength
1698*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1699*0e209d39SAndroid Build Coastguard Worker  */
1700*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1701*0e209d39SAndroid Build Coastguard Worker ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode) __INTRODUCED_IN(31);
1702*0e209d39SAndroid Build Coastguard Worker 
1703*0e209d39SAndroid Build Coastguard Worker 
1704*0e209d39SAndroid Build Coastguard Worker 
1705*0e209d39SAndroid Build Coastguard Worker /**
1706*0e209d39SAndroid Build Coastguard Worker  * Get the logical text position from a visual position.
1707*0e209d39SAndroid Build Coastguard Worker  * If such a mapping is used many times on the same
1708*0e209d39SAndroid Build Coastguard Worker  * <code>UBiDi</code> object, then calling
1709*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_getVisualMap()</code> is more efficient.<p>
1710*0e209d39SAndroid Build Coastguard Worker  *
1711*0e209d39SAndroid Build Coastguard Worker  * The value returned may be <code>#UBIDI_MAP_NOWHERE</code> if there is no
1712*0e209d39SAndroid Build Coastguard Worker  * logical position because the corresponding text character is a Bidi mark
1713*0e209d39SAndroid Build Coastguard Worker  * inserted in the output by option <code>#UBIDI_OPTION_INSERT_MARKS</code>.
1714*0e209d39SAndroid Build Coastguard Worker  * <p>
1715*0e209d39SAndroid Build Coastguard Worker  * This is the inverse function to <code>ubidi_getVisualIndex()</code>.
1716*0e209d39SAndroid Build Coastguard Worker  * <p>
1717*0e209d39SAndroid Build Coastguard Worker  * When the visual output is altered by using options of
1718*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,
1719*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,
1720*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the logical position returned may not
1721*0e209d39SAndroid Build Coastguard Worker  * be correct. It is advised to use, when possible, reordering options
1722*0e209d39SAndroid Build Coastguard Worker  * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.
1723*0e209d39SAndroid Build Coastguard Worker  *
1724*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1725*0e209d39SAndroid Build Coastguard Worker  *
1726*0e209d39SAndroid Build Coastguard Worker  * @param visualIndex is the visual position of a character.
1727*0e209d39SAndroid Build Coastguard Worker  *
1728*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
1729*0e209d39SAndroid Build Coastguard Worker  *
1730*0e209d39SAndroid Build Coastguard Worker  * @return The index of this character in the text.
1731*0e209d39SAndroid Build Coastguard Worker  *
1732*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getVisualMap
1733*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getVisualIndex
1734*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getResultLength
1735*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1736*0e209d39SAndroid Build Coastguard Worker  */
1737*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
1738*0e209d39SAndroid Build Coastguard Worker ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode) __INTRODUCED_IN(31);
1739*0e209d39SAndroid Build Coastguard Worker 
1740*0e209d39SAndroid Build Coastguard Worker 
1741*0e209d39SAndroid Build Coastguard Worker 
1742*0e209d39SAndroid Build Coastguard Worker /**
1743*0e209d39SAndroid Build Coastguard Worker  * Get a logical-to-visual index map (array) for the characters in the UBiDi
1744*0e209d39SAndroid Build Coastguard Worker  * (paragraph or line) object.
1745*0e209d39SAndroid Build Coastguard Worker  * <p>
1746*0e209d39SAndroid Build Coastguard Worker  * Some values in the map may be <code>#UBIDI_MAP_NOWHERE</code> if the
1747*0e209d39SAndroid Build Coastguard Worker  * corresponding text characters are Bidi controls removed from the visual
1748*0e209d39SAndroid Build Coastguard Worker  * output by the option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code>.
1749*0e209d39SAndroid Build Coastguard Worker  * <p>
1750*0e209d39SAndroid Build Coastguard Worker  * When the visual output is altered by using options of
1751*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,
1752*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,
1753*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the visual positions returned may not
1754*0e209d39SAndroid Build Coastguard Worker  * be correct. It is advised to use, when possible, reordering options
1755*0e209d39SAndroid Build Coastguard Worker  * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.
1756*0e209d39SAndroid Build Coastguard Worker  * <p>
1757*0e209d39SAndroid Build Coastguard Worker  * Note that in right-to-left runs, this mapping places
1758*0e209d39SAndroid Build Coastguard Worker  * second surrogates before first ones (which is generally a bad idea)
1759*0e209d39SAndroid Build Coastguard Worker  * and combining characters before base characters.
1760*0e209d39SAndroid Build Coastguard Worker  * Use of <code>ubidi_writeReordered()</code>, optionally with the
1761*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_KEEP_BASE_COMBINING</code> option can be considered instead
1762*0e209d39SAndroid Build Coastguard Worker  * of using the mapping, in order to avoid these issues.
1763*0e209d39SAndroid Build Coastguard Worker  *
1764*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1765*0e209d39SAndroid Build Coastguard Worker  *
1766*0e209d39SAndroid Build Coastguard Worker  * @param indexMap is a pointer to an array of <code>ubidi_getProcessedLength()</code>
1767*0e209d39SAndroid Build Coastguard Worker  *        indexes which will reflect the reordering of the characters.
1768*0e209d39SAndroid Build Coastguard Worker  *        If option <code>#UBIDI_OPTION_INSERT_MARKS</code> is set, the number
1769*0e209d39SAndroid Build Coastguard Worker  *        of elements allocated in <code>indexMap</code> must be no less than
1770*0e209d39SAndroid Build Coastguard Worker  *        <code>ubidi_getResultLength()</code>.
1771*0e209d39SAndroid Build Coastguard Worker  *        The array does not need to be initialized.<br><br>
1772*0e209d39SAndroid Build Coastguard Worker  *        The index map will result in <code>indexMap[logicalIndex]==visualIndex</code>.
1773*0e209d39SAndroid Build Coastguard Worker  *
1774*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
1775*0e209d39SAndroid Build Coastguard Worker  *
1776*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getVisualMap
1777*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getVisualIndex
1778*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getProcessedLength
1779*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getResultLength
1780*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1781*0e209d39SAndroid Build Coastguard Worker  */
1782*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1783*0e209d39SAndroid Build Coastguard Worker ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode) __INTRODUCED_IN(31);
1784*0e209d39SAndroid Build Coastguard Worker 
1785*0e209d39SAndroid Build Coastguard Worker 
1786*0e209d39SAndroid Build Coastguard Worker 
1787*0e209d39SAndroid Build Coastguard Worker /**
1788*0e209d39SAndroid Build Coastguard Worker  * Get a visual-to-logical index map (array) for the characters in the UBiDi
1789*0e209d39SAndroid Build Coastguard Worker  * (paragraph or line) object.
1790*0e209d39SAndroid Build Coastguard Worker  * <p>
1791*0e209d39SAndroid Build Coastguard Worker  * Some values in the map may be <code>#UBIDI_MAP_NOWHERE</code> if the
1792*0e209d39SAndroid Build Coastguard Worker  * corresponding text characters are Bidi marks inserted in the visual output
1793*0e209d39SAndroid Build Coastguard Worker  * by the option <code>#UBIDI_OPTION_INSERT_MARKS</code>.
1794*0e209d39SAndroid Build Coastguard Worker  * <p>
1795*0e209d39SAndroid Build Coastguard Worker  * When the visual output is altered by using options of
1796*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_writeReordered()</code> such as <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>,
1797*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_KEEP_BASE_COMBINING</code>, <code>UBIDI_OUTPUT_REVERSE</code>,
1798*0e209d39SAndroid Build Coastguard Worker  * <code>UBIDI_REMOVE_BIDI_CONTROLS</code>, the logical positions returned may not
1799*0e209d39SAndroid Build Coastguard Worker  * be correct. It is advised to use, when possible, reordering options
1800*0e209d39SAndroid Build Coastguard Worker  * such as <code>UBIDI_OPTION_INSERT_MARKS</code> and <code>UBIDI_OPTION_REMOVE_CONTROLS</code>.
1801*0e209d39SAndroid Build Coastguard Worker  *
1802*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph or line <code>UBiDi</code> object.
1803*0e209d39SAndroid Build Coastguard Worker  *
1804*0e209d39SAndroid Build Coastguard Worker  * @param indexMap is a pointer to an array of <code>ubidi_getResultLength()</code>
1805*0e209d39SAndroid Build Coastguard Worker  *        indexes which will reflect the reordering of the characters.
1806*0e209d39SAndroid Build Coastguard Worker  *        If option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> is set, the number
1807*0e209d39SAndroid Build Coastguard Worker  *        of elements allocated in <code>indexMap</code> must be no less than
1808*0e209d39SAndroid Build Coastguard Worker  *        <code>ubidi_getProcessedLength()</code>.
1809*0e209d39SAndroid Build Coastguard Worker  *        The array does not need to be initialized.<br><br>
1810*0e209d39SAndroid Build Coastguard Worker  *        The index map will result in <code>indexMap[visualIndex]==logicalIndex</code>.
1811*0e209d39SAndroid Build Coastguard Worker  *
1812*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
1813*0e209d39SAndroid Build Coastguard Worker  *
1814*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getLogicalMap
1815*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getLogicalIndex
1816*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getProcessedLength
1817*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getResultLength
1818*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1819*0e209d39SAndroid Build Coastguard Worker  */
1820*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1821*0e209d39SAndroid Build Coastguard Worker ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode) __INTRODUCED_IN(31);
1822*0e209d39SAndroid Build Coastguard Worker 
1823*0e209d39SAndroid Build Coastguard Worker 
1824*0e209d39SAndroid Build Coastguard Worker 
1825*0e209d39SAndroid Build Coastguard Worker /**
1826*0e209d39SAndroid Build Coastguard Worker  * This is a convenience function that does not use a UBiDi object.
1827*0e209d39SAndroid Build Coastguard Worker  * It is intended to be used for when an application has determined the levels
1828*0e209d39SAndroid Build Coastguard Worker  * of objects (character sequences) and just needs to have them reordered (L2).
1829*0e209d39SAndroid Build Coastguard Worker  * This is equivalent to using <code>ubidi_getLogicalMap()</code> on a
1830*0e209d39SAndroid Build Coastguard Worker  * <code>UBiDi</code> object.
1831*0e209d39SAndroid Build Coastguard Worker  *
1832*0e209d39SAndroid Build Coastguard Worker  * @param levels is an array with <code>length</code> levels that have been determined by
1833*0e209d39SAndroid Build Coastguard Worker  *        the application.
1834*0e209d39SAndroid Build Coastguard Worker  *
1835*0e209d39SAndroid Build Coastguard Worker  * @param length is the number of levels in the array, or, semantically,
1836*0e209d39SAndroid Build Coastguard Worker  *        the number of objects to be reordered.
1837*0e209d39SAndroid Build Coastguard Worker  *        It must be <code>length>0</code>.
1838*0e209d39SAndroid Build Coastguard Worker  *
1839*0e209d39SAndroid Build Coastguard Worker  * @param indexMap is a pointer to an array of <code>length</code>
1840*0e209d39SAndroid Build Coastguard Worker  *        indexes which will reflect the reordering of the characters.
1841*0e209d39SAndroid Build Coastguard Worker  *        The array does not need to be initialized.<p>
1842*0e209d39SAndroid Build Coastguard Worker  *        The index map will result in <code>indexMap[logicalIndex]==visualIndex</code>.
1843*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1844*0e209d39SAndroid Build Coastguard Worker  */
1845*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1846*0e209d39SAndroid Build Coastguard Worker ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap) __INTRODUCED_IN(31);
1847*0e209d39SAndroid Build Coastguard Worker 
1848*0e209d39SAndroid Build Coastguard Worker 
1849*0e209d39SAndroid Build Coastguard Worker 
1850*0e209d39SAndroid Build Coastguard Worker /**
1851*0e209d39SAndroid Build Coastguard Worker  * This is a convenience function that does not use a UBiDi object.
1852*0e209d39SAndroid Build Coastguard Worker  * It is intended to be used for when an application has determined the levels
1853*0e209d39SAndroid Build Coastguard Worker  * of objects (character sequences) and just needs to have them reordered (L2).
1854*0e209d39SAndroid Build Coastguard Worker  * This is equivalent to using <code>ubidi_getVisualMap()</code> on a
1855*0e209d39SAndroid Build Coastguard Worker  * <code>UBiDi</code> object.
1856*0e209d39SAndroid Build Coastguard Worker  *
1857*0e209d39SAndroid Build Coastguard Worker  * @param levels is an array with <code>length</code> levels that have been determined by
1858*0e209d39SAndroid Build Coastguard Worker  *        the application.
1859*0e209d39SAndroid Build Coastguard Worker  *
1860*0e209d39SAndroid Build Coastguard Worker  * @param length is the number of levels in the array, or, semantically,
1861*0e209d39SAndroid Build Coastguard Worker  *        the number of objects to be reordered.
1862*0e209d39SAndroid Build Coastguard Worker  *        It must be <code>length>0</code>.
1863*0e209d39SAndroid Build Coastguard Worker  *
1864*0e209d39SAndroid Build Coastguard Worker  * @param indexMap is a pointer to an array of <code>length</code>
1865*0e209d39SAndroid Build Coastguard Worker  *        indexes which will reflect the reordering of the characters.
1866*0e209d39SAndroid Build Coastguard Worker  *        The array does not need to be initialized.<p>
1867*0e209d39SAndroid Build Coastguard Worker  *        The index map will result in <code>indexMap[visualIndex]==logicalIndex</code>.
1868*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1869*0e209d39SAndroid Build Coastguard Worker  */
1870*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1871*0e209d39SAndroid Build Coastguard Worker ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap) __INTRODUCED_IN(31);
1872*0e209d39SAndroid Build Coastguard Worker 
1873*0e209d39SAndroid Build Coastguard Worker 
1874*0e209d39SAndroid Build Coastguard Worker 
1875*0e209d39SAndroid Build Coastguard Worker /**
1876*0e209d39SAndroid Build Coastguard Worker  * Invert an index map.
1877*0e209d39SAndroid Build Coastguard Worker  * The index mapping of the first map is inverted and written to
1878*0e209d39SAndroid Build Coastguard Worker  * the second one.
1879*0e209d39SAndroid Build Coastguard Worker  *
1880*0e209d39SAndroid Build Coastguard Worker  * @param srcMap is an array with <code>length</code> elements
1881*0e209d39SAndroid Build Coastguard Worker  *        which defines the original mapping from a source array containing
1882*0e209d39SAndroid Build Coastguard Worker  *        <code>length</code> elements to a destination array.
1883*0e209d39SAndroid Build Coastguard Worker  *        Some elements of the source array may have no mapping in the
1884*0e209d39SAndroid Build Coastguard Worker  *        destination array. In that case, their value will be
1885*0e209d39SAndroid Build Coastguard Worker  *        the special value <code>UBIDI_MAP_NOWHERE</code>.
1886*0e209d39SAndroid Build Coastguard Worker  *        All elements must be >=0 or equal to <code>UBIDI_MAP_NOWHERE</code>.
1887*0e209d39SAndroid Build Coastguard Worker  *        Some elements may have a value >= <code>length</code>, if the
1888*0e209d39SAndroid Build Coastguard Worker  *        destination array has more elements than the source array.
1889*0e209d39SAndroid Build Coastguard Worker  *        There must be no duplicate indexes (two or more elements with the
1890*0e209d39SAndroid Build Coastguard Worker  *        same value except <code>UBIDI_MAP_NOWHERE</code>).
1891*0e209d39SAndroid Build Coastguard Worker  *
1892*0e209d39SAndroid Build Coastguard Worker  * @param destMap is an array with a number of elements equal to 1 + the highest
1893*0e209d39SAndroid Build Coastguard Worker  *        value in <code>srcMap</code>.
1894*0e209d39SAndroid Build Coastguard Worker  *        <code>destMap</code> will be filled with the inverse mapping.
1895*0e209d39SAndroid Build Coastguard Worker  *        If element with index i in <code>srcMap</code> has a value k different
1896*0e209d39SAndroid Build Coastguard Worker  *        from <code>UBIDI_MAP_NOWHERE</code>, this means that element i of
1897*0e209d39SAndroid Build Coastguard Worker  *        the source array maps to element k in the destination array.
1898*0e209d39SAndroid Build Coastguard Worker  *        The inverse map will have value i in its k-th element.
1899*0e209d39SAndroid Build Coastguard Worker  *        For all elements of the destination array which do not map to
1900*0e209d39SAndroid Build Coastguard Worker  *        an element in the source array, the corresponding element in the
1901*0e209d39SAndroid Build Coastguard Worker  *        inverse map will have a value equal to <code>UBIDI_MAP_NOWHERE</code>.
1902*0e209d39SAndroid Build Coastguard Worker  *
1903*0e209d39SAndroid Build Coastguard Worker  * @param length is the length of each array.
1904*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_MAP_NOWHERE
1905*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1906*0e209d39SAndroid Build Coastguard Worker  */
1907*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
1908*0e209d39SAndroid Build Coastguard Worker ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length) __INTRODUCED_IN(31);
1909*0e209d39SAndroid Build Coastguard Worker 
1910*0e209d39SAndroid Build Coastguard Worker 
1911*0e209d39SAndroid Build Coastguard Worker 
1912*0e209d39SAndroid Build Coastguard Worker /** option flags for ubidi_writeReordered() */
1913*0e209d39SAndroid Build Coastguard Worker 
1914*0e209d39SAndroid Build Coastguard Worker /**
1915*0e209d39SAndroid Build Coastguard Worker  * option bit for ubidi_writeReordered():
1916*0e209d39SAndroid Build Coastguard Worker  * keep combining characters after their base characters in RTL runs
1917*0e209d39SAndroid Build Coastguard Worker  *
1918*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_writeReordered
1919*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1920*0e209d39SAndroid Build Coastguard Worker  */
1921*0e209d39SAndroid Build Coastguard Worker #define UBIDI_KEEP_BASE_COMBINING       1
1922*0e209d39SAndroid Build Coastguard Worker 
1923*0e209d39SAndroid Build Coastguard Worker /**
1924*0e209d39SAndroid Build Coastguard Worker  * option bit for ubidi_writeReordered():
1925*0e209d39SAndroid Build Coastguard Worker  * replace characters with the "mirrored" property in RTL runs
1926*0e209d39SAndroid Build Coastguard Worker  * by their mirror-image mappings
1927*0e209d39SAndroid Build Coastguard Worker  *
1928*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_writeReordered
1929*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1930*0e209d39SAndroid Build Coastguard Worker  */
1931*0e209d39SAndroid Build Coastguard Worker #define UBIDI_DO_MIRRORING              2
1932*0e209d39SAndroid Build Coastguard Worker 
1933*0e209d39SAndroid Build Coastguard Worker /**
1934*0e209d39SAndroid Build Coastguard Worker  * option bit for ubidi_writeReordered():
1935*0e209d39SAndroid Build Coastguard Worker  * surround the run with LRMs if necessary;
1936*0e209d39SAndroid Build Coastguard Worker  * this is part of the approximate "inverse Bidi" algorithm
1937*0e209d39SAndroid Build Coastguard Worker  *
1938*0e209d39SAndroid Build Coastguard Worker  * <p>This option does not imply corresponding adjustment of the index
1939*0e209d39SAndroid Build Coastguard Worker  * mappings.</p>
1940*0e209d39SAndroid Build Coastguard Worker  *
1941*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setInverse
1942*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_writeReordered
1943*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1944*0e209d39SAndroid Build Coastguard Worker  */
1945*0e209d39SAndroid Build Coastguard Worker #define UBIDI_INSERT_LRM_FOR_NUMERIC    4
1946*0e209d39SAndroid Build Coastguard Worker 
1947*0e209d39SAndroid Build Coastguard Worker /**
1948*0e209d39SAndroid Build Coastguard Worker  * option bit for ubidi_writeReordered():
1949*0e209d39SAndroid Build Coastguard Worker  * remove Bidi control characters
1950*0e209d39SAndroid Build Coastguard Worker  * (this does not affect #UBIDI_INSERT_LRM_FOR_NUMERIC)
1951*0e209d39SAndroid Build Coastguard Worker  *
1952*0e209d39SAndroid Build Coastguard Worker  * <p>This option does not imply corresponding adjustment of the index
1953*0e209d39SAndroid Build Coastguard Worker  * mappings.</p>
1954*0e209d39SAndroid Build Coastguard Worker  *
1955*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_writeReordered
1956*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1957*0e209d39SAndroid Build Coastguard Worker  */
1958*0e209d39SAndroid Build Coastguard Worker #define UBIDI_REMOVE_BIDI_CONTROLS      8
1959*0e209d39SAndroid Build Coastguard Worker 
1960*0e209d39SAndroid Build Coastguard Worker /**
1961*0e209d39SAndroid Build Coastguard Worker  * option bit for ubidi_writeReordered():
1962*0e209d39SAndroid Build Coastguard Worker  * write the output in reverse order
1963*0e209d39SAndroid Build Coastguard Worker  *
1964*0e209d39SAndroid Build Coastguard Worker  * <p>This has the same effect as calling <code>ubidi_writeReordered()</code>
1965*0e209d39SAndroid Build Coastguard Worker  * first without this option, and then calling
1966*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_writeReverse()</code> without mirroring.
1967*0e209d39SAndroid Build Coastguard Worker  * Doing this in the same step is faster and avoids a temporary buffer.
1968*0e209d39SAndroid Build Coastguard Worker  * An example for using this option is output to a character terminal that
1969*0e209d39SAndroid Build Coastguard Worker  * is designed for RTL scripts and stores text in reverse order.</p>
1970*0e209d39SAndroid Build Coastguard Worker  *
1971*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_writeReordered
1972*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
1973*0e209d39SAndroid Build Coastguard Worker  */
1974*0e209d39SAndroid Build Coastguard Worker #define UBIDI_OUTPUT_REVERSE            16
1975*0e209d39SAndroid Build Coastguard Worker 
1976*0e209d39SAndroid Build Coastguard Worker /**
1977*0e209d39SAndroid Build Coastguard Worker  * Get the length of the source text processed by the last call to
1978*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setPara()</code>. This length may be different from the length
1979*0e209d39SAndroid Build Coastguard Worker  * of the source text if option <code>#UBIDI_OPTION_STREAMING</code>
1980*0e209d39SAndroid Build Coastguard Worker  * has been set.
1981*0e209d39SAndroid Build Coastguard Worker  * <br>
1982*0e209d39SAndroid Build Coastguard Worker  * Note that whenever the length of the text affects the execution or the
1983*0e209d39SAndroid Build Coastguard Worker  * result of a function, it is the processed length which must be considered,
1984*0e209d39SAndroid Build Coastguard Worker  * except for <code>ubidi_setPara</code> (which receives unprocessed source
1985*0e209d39SAndroid Build Coastguard Worker  * text) and <code>ubidi_getLength</code> (which returns the original length
1986*0e209d39SAndroid Build Coastguard Worker  * of the source text).<br>
1987*0e209d39SAndroid Build Coastguard Worker  * In particular, the processed length is the one to consider in the following
1988*0e209d39SAndroid Build Coastguard Worker  * cases:
1989*0e209d39SAndroid Build Coastguard Worker  * <ul>
1990*0e209d39SAndroid Build Coastguard Worker  * <li>maximum value of the <code>limit</code> argument of
1991*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setLine</code></li>
1992*0e209d39SAndroid Build Coastguard Worker  * <li>maximum value of the <code>charIndex</code> argument of
1993*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_getParagraph</code></li>
1994*0e209d39SAndroid Build Coastguard Worker  * <li>maximum value of the <code>charIndex</code> argument of
1995*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_getLevelAt</code></li>
1996*0e209d39SAndroid Build Coastguard Worker  * <li>number of elements in the array returned by <code>ubidi_getLevels</code></li>
1997*0e209d39SAndroid Build Coastguard Worker  * <li>maximum value of the <code>logicalStart</code> argument of
1998*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_getLogicalRun</code></li>
1999*0e209d39SAndroid Build Coastguard Worker  * <li>maximum value of the <code>logicalIndex</code> argument of
2000*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_getVisualIndex</code></li>
2001*0e209d39SAndroid Build Coastguard Worker  * <li>number of elements filled in the <code>*indexMap</code> argument of
2002*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_getLogicalMap</code></li>
2003*0e209d39SAndroid Build Coastguard Worker  * <li>length of text processed by <code>ubidi_writeReordered</code></li>
2004*0e209d39SAndroid Build Coastguard Worker  * </ul>
2005*0e209d39SAndroid Build Coastguard Worker  *
2006*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph <code>UBiDi</code> object.
2007*0e209d39SAndroid Build Coastguard Worker  *
2008*0e209d39SAndroid Build Coastguard Worker  * @return The length of the part of the source text processed by
2009*0e209d39SAndroid Build Coastguard Worker  *         the last call to <code>ubidi_setPara</code>.
2010*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setPara
2011*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_OPTION_STREAMING
2012*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
2013*0e209d39SAndroid Build Coastguard Worker  */
2014*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
2015*0e209d39SAndroid Build Coastguard Worker ubidi_getProcessedLength(const UBiDi *pBiDi) __INTRODUCED_IN(31);
2016*0e209d39SAndroid Build Coastguard Worker 
2017*0e209d39SAndroid Build Coastguard Worker 
2018*0e209d39SAndroid Build Coastguard Worker 
2019*0e209d39SAndroid Build Coastguard Worker /**
2020*0e209d39SAndroid Build Coastguard Worker  * Get the length of the reordered text resulting from the last call to
2021*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setPara()</code>. This length may be different from the length
2022*0e209d39SAndroid Build Coastguard Worker  * of the source text if option <code>#UBIDI_OPTION_INSERT_MARKS</code>
2023*0e209d39SAndroid Build Coastguard Worker  * or option <code>#UBIDI_OPTION_REMOVE_CONTROLS</code> has been set.
2024*0e209d39SAndroid Build Coastguard Worker  * <br>
2025*0e209d39SAndroid Build Coastguard Worker  * This resulting length is the one to consider in the following cases:
2026*0e209d39SAndroid Build Coastguard Worker  * <ul>
2027*0e209d39SAndroid Build Coastguard Worker  * <li>maximum value of the <code>visualIndex</code> argument of
2028*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_getLogicalIndex</code></li>
2029*0e209d39SAndroid Build Coastguard Worker  * <li>number of elements of the <code>*indexMap</code> argument of
2030*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_getVisualMap</code></li>
2031*0e209d39SAndroid Build Coastguard Worker  * </ul>
2032*0e209d39SAndroid Build Coastguard Worker  * Note that this length stays identical to the source text length if
2033*0e209d39SAndroid Build Coastguard Worker  * Bidi marks are inserted or removed using option bits of
2034*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_writeReordered</code>, or if option
2035*0e209d39SAndroid Build Coastguard Worker  * <code>#UBIDI_REORDER_INVERSE_NUMBERS_AS_L</code> has been set.
2036*0e209d39SAndroid Build Coastguard Worker  *
2037*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph <code>UBiDi</code> object.
2038*0e209d39SAndroid Build Coastguard Worker  *
2039*0e209d39SAndroid Build Coastguard Worker  * @return The length of the reordered text resulting from
2040*0e209d39SAndroid Build Coastguard Worker  *         the last call to <code>ubidi_setPara</code>.
2041*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setPara
2042*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_OPTION_INSERT_MARKS
2043*0e209d39SAndroid Build Coastguard Worker  * @see UBIDI_OPTION_REMOVE_CONTROLS
2044*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
2045*0e209d39SAndroid Build Coastguard Worker  */
2046*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
2047*0e209d39SAndroid Build Coastguard Worker ubidi_getResultLength(const UBiDi *pBiDi) __INTRODUCED_IN(31);
2048*0e209d39SAndroid Build Coastguard Worker 
2049*0e209d39SAndroid Build Coastguard Worker 
2050*0e209d39SAndroid Build Coastguard Worker 
2051*0e209d39SAndroid Build Coastguard Worker U_CDECL_BEGIN
2052*0e209d39SAndroid Build Coastguard Worker 
2053*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API
2054*0e209d39SAndroid Build Coastguard Worker /**
2055*0e209d39SAndroid Build Coastguard Worker  * Value returned by <code>UBiDiClassCallback</code> callbacks when
2056*0e209d39SAndroid Build Coastguard Worker  * there is no need to override the standard Bidi class for a given code point.
2057*0e209d39SAndroid Build Coastguard Worker  *
2058*0e209d39SAndroid Build Coastguard Worker  * This constant is deprecated; use u_getIntPropertyMaxValue(UCHAR_BIDI_CLASS)+1 instead.
2059*0e209d39SAndroid Build Coastguard Worker  *
2060*0e209d39SAndroid Build Coastguard Worker  * @see UBiDiClassCallback
2061*0e209d39SAndroid Build Coastguard Worker  * \xrefitem deprecated "Deprecated" "Deprecated List" ICU 58 The numeric value may change over time, see ICU ticket #12420.
2062*0e209d39SAndroid Build Coastguard Worker  */
2063*0e209d39SAndroid Build Coastguard Worker #define U_BIDI_CLASS_DEFAULT  U_CHAR_DIRECTION_COUNT
2064*0e209d39SAndroid Build Coastguard Worker #endif  // U_HIDE_DEPRECATED_API
2065*0e209d39SAndroid Build Coastguard Worker 
2066*0e209d39SAndroid Build Coastguard Worker /**
2067*0e209d39SAndroid Build Coastguard Worker  * Callback type declaration for overriding default Bidi class values with
2068*0e209d39SAndroid Build Coastguard Worker  * custom ones.
2069*0e209d39SAndroid Build Coastguard Worker  * <p>Usually, the function pointer will be propagated to a <code>UBiDi</code>
2070*0e209d39SAndroid Build Coastguard Worker  * object by calling the <code>ubidi_setClassCallback()</code> function;
2071*0e209d39SAndroid Build Coastguard Worker  * then the callback will be invoked by the UBA implementation any time the
2072*0e209d39SAndroid Build Coastguard Worker  * class of a character is to be determined.</p>
2073*0e209d39SAndroid Build Coastguard Worker  *
2074*0e209d39SAndroid Build Coastguard Worker  * @param context is a pointer to the callback private data.
2075*0e209d39SAndroid Build Coastguard Worker  *
2076*0e209d39SAndroid Build Coastguard Worker  * @param c       is the code point to get a Bidi class for.
2077*0e209d39SAndroid Build Coastguard Worker  *
2078*0e209d39SAndroid Build Coastguard Worker  * @return The directional property / Bidi class for the given code point
2079*0e209d39SAndroid Build Coastguard Worker  *         <code>c</code> if the default class has been overridden, or
2080*0e209d39SAndroid Build Coastguard Worker  *         <code>u_getIntPropertyMaxValue(UCHAR_BIDI_CLASS)+1</code>
2081*0e209d39SAndroid Build Coastguard Worker  *         if the standard Bidi class value for <code>c</code> is to be used.
2082*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setClassCallback
2083*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getClassCallback
2084*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
2085*0e209d39SAndroid Build Coastguard Worker  */
2086*0e209d39SAndroid Build Coastguard Worker typedef UCharDirection U_CALLCONV
2087*0e209d39SAndroid Build Coastguard Worker UBiDiClassCallback(const void *context, UChar32 c);
2088*0e209d39SAndroid Build Coastguard Worker 
2089*0e209d39SAndroid Build Coastguard Worker U_CDECL_END
2090*0e209d39SAndroid Build Coastguard Worker 
2091*0e209d39SAndroid Build Coastguard Worker /**
2092*0e209d39SAndroid Build Coastguard Worker  * Retrieve the Bidi class for a given code point.
2093*0e209d39SAndroid Build Coastguard Worker  * <p>If a <code>#UBiDiClassCallback</code> callback is defined and returns a
2094*0e209d39SAndroid Build Coastguard Worker  * value other than <code>u_getIntPropertyMaxValue(UCHAR_BIDI_CLASS)+1</code>,
2095*0e209d39SAndroid Build Coastguard Worker  * that value is used; otherwise the default class determination mechanism is invoked.</p>
2096*0e209d39SAndroid Build Coastguard Worker  *
2097*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph <code>UBiDi</code> object.
2098*0e209d39SAndroid Build Coastguard Worker  *
2099*0e209d39SAndroid Build Coastguard Worker  * @param c     is the code point whose Bidi class must be retrieved.
2100*0e209d39SAndroid Build Coastguard Worker  *
2101*0e209d39SAndroid Build Coastguard Worker  * @return The Bidi class for character <code>c</code> based
2102*0e209d39SAndroid Build Coastguard Worker  *         on the given <code>pBiDi</code> instance.
2103*0e209d39SAndroid Build Coastguard Worker  * @see UBiDiClassCallback
2104*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
2105*0e209d39SAndroid Build Coastguard Worker  */
2106*0e209d39SAndroid Build Coastguard Worker U_CAPI UCharDirection U_EXPORT2
2107*0e209d39SAndroid Build Coastguard Worker ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c) __INTRODUCED_IN(31);
2108*0e209d39SAndroid Build Coastguard Worker 
2109*0e209d39SAndroid Build Coastguard Worker 
2110*0e209d39SAndroid Build Coastguard Worker 
2111*0e209d39SAndroid Build Coastguard Worker /**
2112*0e209d39SAndroid Build Coastguard Worker  * Set the callback function and callback data used by the UBA
2113*0e209d39SAndroid Build Coastguard Worker  * implementation for Bidi class determination.
2114*0e209d39SAndroid Build Coastguard Worker  * <p>This may be useful for assigning Bidi classes to PUA characters, or
2115*0e209d39SAndroid Build Coastguard Worker  * for special application needs. For instance, an application may want to
2116*0e209d39SAndroid Build Coastguard Worker  * handle all spaces like L or R characters (according to the base direction)
2117*0e209d39SAndroid Build Coastguard Worker  * when creating the visual ordering of logical lines which are part of a report
2118*0e209d39SAndroid Build Coastguard Worker  * organized in columns: there should not be interaction between adjacent
2119*0e209d39SAndroid Build Coastguard Worker  * cells.<p>
2120*0e209d39SAndroid Build Coastguard Worker  *
2121*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph <code>UBiDi</code> object.
2122*0e209d39SAndroid Build Coastguard Worker  *
2123*0e209d39SAndroid Build Coastguard Worker  * @param newFn is the new callback function pointer.
2124*0e209d39SAndroid Build Coastguard Worker  *
2125*0e209d39SAndroid Build Coastguard Worker  * @param newContext is the new callback context pointer. This can be NULL.
2126*0e209d39SAndroid Build Coastguard Worker  *
2127*0e209d39SAndroid Build Coastguard Worker  * @param oldFn fillin: Returns the old callback function pointer. This can be
2128*0e209d39SAndroid Build Coastguard Worker  *                      NULL.
2129*0e209d39SAndroid Build Coastguard Worker  *
2130*0e209d39SAndroid Build Coastguard Worker  * @param oldContext fillin: Returns the old callback's context. This can be
2131*0e209d39SAndroid Build Coastguard Worker  *                           NULL.
2132*0e209d39SAndroid Build Coastguard Worker  *
2133*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
2134*0e209d39SAndroid Build Coastguard Worker  *
2135*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getClassCallback
2136*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
2137*0e209d39SAndroid Build Coastguard Worker  */
2138*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
2139*0e209d39SAndroid Build Coastguard Worker ubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn,
2140*0e209d39SAndroid Build Coastguard Worker                        const void *newContext, UBiDiClassCallback **oldFn,
2141*0e209d39SAndroid Build Coastguard Worker                        const void **oldContext, UErrorCode *pErrorCode) __INTRODUCED_IN(31);
2142*0e209d39SAndroid Build Coastguard Worker 
2143*0e209d39SAndroid Build Coastguard Worker 
2144*0e209d39SAndroid Build Coastguard Worker 
2145*0e209d39SAndroid Build Coastguard Worker /**
2146*0e209d39SAndroid Build Coastguard Worker  * Get the current callback function used for Bidi class determination.
2147*0e209d39SAndroid Build Coastguard Worker  *
2148*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi is the paragraph <code>UBiDi</code> object.
2149*0e209d39SAndroid Build Coastguard Worker  *
2150*0e209d39SAndroid Build Coastguard Worker  * @param fn fillin: Returns the callback function pointer.
2151*0e209d39SAndroid Build Coastguard Worker  *
2152*0e209d39SAndroid Build Coastguard Worker  * @param context fillin: Returns the callback's private context.
2153*0e209d39SAndroid Build Coastguard Worker  *
2154*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_setClassCallback
2155*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 3.6
2156*0e209d39SAndroid Build Coastguard Worker  */
2157*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
2158*0e209d39SAndroid Build Coastguard Worker ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context) __INTRODUCED_IN(31);
2159*0e209d39SAndroid Build Coastguard Worker 
2160*0e209d39SAndroid Build Coastguard Worker 
2161*0e209d39SAndroid Build Coastguard Worker 
2162*0e209d39SAndroid Build Coastguard Worker /**
2163*0e209d39SAndroid Build Coastguard Worker  * Take a <code>UBiDi</code> object containing the reordering
2164*0e209d39SAndroid Build Coastguard Worker  * information for a piece of text (one or more paragraphs) set by
2165*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setPara()</code> or for a line of text set by
2166*0e209d39SAndroid Build Coastguard Worker  * <code>ubidi_setLine()</code> and write a reordered string to the
2167*0e209d39SAndroid Build Coastguard Worker  * destination buffer.
2168*0e209d39SAndroid Build Coastguard Worker  *
2169*0e209d39SAndroid Build Coastguard Worker  * This function preserves the integrity of characters with multiple
2170*0e209d39SAndroid Build Coastguard Worker  * code units and (optionally) combining characters.
2171*0e209d39SAndroid Build Coastguard Worker  * Characters in RTL runs can be replaced by mirror-image characters
2172*0e209d39SAndroid Build Coastguard Worker  * in the destination buffer. Note that "real" mirroring has
2173*0e209d39SAndroid Build Coastguard Worker  * to be done in a rendering engine by glyph selection
2174*0e209d39SAndroid Build Coastguard Worker  * and that for many "mirrored" characters there are no
2175*0e209d39SAndroid Build Coastguard Worker  * Unicode characters as mirror-image equivalents.
2176*0e209d39SAndroid Build Coastguard Worker  * There are also options to insert or remove Bidi control
2177*0e209d39SAndroid Build Coastguard Worker  * characters; see the description of the <code>destSize</code>
2178*0e209d39SAndroid Build Coastguard Worker  * and <code>options</code> parameters and of the option bit flags.
2179*0e209d39SAndroid Build Coastguard Worker  *
2180*0e209d39SAndroid Build Coastguard Worker  * @param pBiDi A pointer to a <code>UBiDi</code> object that
2181*0e209d39SAndroid Build Coastguard Worker  *              is set by <code>ubidi_setPara()</code> or
2182*0e209d39SAndroid Build Coastguard Worker  *              <code>ubidi_setLine()</code> and contains the reordering
2183*0e209d39SAndroid Build Coastguard Worker  *              information for the text that it was defined for,
2184*0e209d39SAndroid Build Coastguard Worker  *              as well as a pointer to that text.<br><br>
2185*0e209d39SAndroid Build Coastguard Worker  *              The text was aliased (only the pointer was stored
2186*0e209d39SAndroid Build Coastguard Worker  *              without copying the contents) and must not have been modified
2187*0e209d39SAndroid Build Coastguard Worker  *              since the <code>ubidi_setPara()</code> call.
2188*0e209d39SAndroid Build Coastguard Worker  *
2189*0e209d39SAndroid Build Coastguard Worker  * @param dest A pointer to where the reordered text is to be copied.
2190*0e209d39SAndroid Build Coastguard Worker  *             The source text and <code>dest[destSize]</code>
2191*0e209d39SAndroid Build Coastguard Worker  *             must not overlap.
2192*0e209d39SAndroid Build Coastguard Worker  *
2193*0e209d39SAndroid Build Coastguard Worker  * @param destSize The size of the <code>dest</code> buffer,
2194*0e209d39SAndroid Build Coastguard Worker  *                 in number of UChars.
2195*0e209d39SAndroid Build Coastguard Worker  *                 If the <code>UBIDI_INSERT_LRM_FOR_NUMERIC</code>
2196*0e209d39SAndroid Build Coastguard Worker  *                 option is set, then the destination length could be
2197*0e209d39SAndroid Build Coastguard Worker  *                 as large as
2198*0e209d39SAndroid Build Coastguard Worker  *                 <code>ubidi_getLength(pBiDi)+2*ubidi_countRuns(pBiDi)</code>.
2199*0e209d39SAndroid Build Coastguard Worker  *                 If the <code>UBIDI_REMOVE_BIDI_CONTROLS</code> option
2200*0e209d39SAndroid Build Coastguard Worker  *                 is set, then the destination length may be less than
2201*0e209d39SAndroid Build Coastguard Worker  *                 <code>ubidi_getLength(pBiDi)</code>.
2202*0e209d39SAndroid Build Coastguard Worker  *                 If none of these options is set, then the destination length
2203*0e209d39SAndroid Build Coastguard Worker  *                 will be exactly <code>ubidi_getProcessedLength(pBiDi)</code>.
2204*0e209d39SAndroid Build Coastguard Worker  *
2205*0e209d39SAndroid Build Coastguard Worker  * @param options A bit set of options for the reordering that control
2206*0e209d39SAndroid Build Coastguard Worker  *                how the reordered text is written.
2207*0e209d39SAndroid Build Coastguard Worker  *                The options include mirroring the characters on a code
2208*0e209d39SAndroid Build Coastguard Worker  *                point basis and inserting LRM characters, which is used
2209*0e209d39SAndroid Build Coastguard Worker  *                especially for transforming visually stored text
2210*0e209d39SAndroid Build Coastguard Worker  *                to logically stored text (although this is still an
2211*0e209d39SAndroid Build Coastguard Worker  *                imperfect implementation of an "inverse Bidi" algorithm
2212*0e209d39SAndroid Build Coastguard Worker  *                because it uses the "forward Bidi" algorithm at its core).
2213*0e209d39SAndroid Build Coastguard Worker  *                The available options are:
2214*0e209d39SAndroid Build Coastguard Worker  *                <code>#UBIDI_DO_MIRRORING</code>,
2215*0e209d39SAndroid Build Coastguard Worker  *                <code>#UBIDI_INSERT_LRM_FOR_NUMERIC</code>,
2216*0e209d39SAndroid Build Coastguard Worker  *                <code>#UBIDI_KEEP_BASE_COMBINING</code>,
2217*0e209d39SAndroid Build Coastguard Worker  *                <code>#UBIDI_OUTPUT_REVERSE</code>,
2218*0e209d39SAndroid Build Coastguard Worker  *                <code>#UBIDI_REMOVE_BIDI_CONTROLS</code>
2219*0e209d39SAndroid Build Coastguard Worker  *
2220*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
2221*0e209d39SAndroid Build Coastguard Worker  *
2222*0e209d39SAndroid Build Coastguard Worker  * @return The length of the output string.
2223*0e209d39SAndroid Build Coastguard Worker  *
2224*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_getProcessedLength
2225*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
2226*0e209d39SAndroid Build Coastguard Worker  */
2227*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
2228*0e209d39SAndroid Build Coastguard Worker ubidi_writeReordered(UBiDi *pBiDi,
2229*0e209d39SAndroid Build Coastguard Worker                      UChar *dest, int32_t destSize,
2230*0e209d39SAndroid Build Coastguard Worker                      uint16_t options,
2231*0e209d39SAndroid Build Coastguard Worker                      UErrorCode *pErrorCode) __INTRODUCED_IN(31);
2232*0e209d39SAndroid Build Coastguard Worker 
2233*0e209d39SAndroid Build Coastguard Worker 
2234*0e209d39SAndroid Build Coastguard Worker 
2235*0e209d39SAndroid Build Coastguard Worker /**
2236*0e209d39SAndroid Build Coastguard Worker  * Reverse a Right-To-Left run of Unicode text.
2237*0e209d39SAndroid Build Coastguard Worker  *
2238*0e209d39SAndroid Build Coastguard Worker  * This function preserves the integrity of characters with multiple
2239*0e209d39SAndroid Build Coastguard Worker  * code units and (optionally) combining characters.
2240*0e209d39SAndroid Build Coastguard Worker  * Characters can be replaced by mirror-image characters
2241*0e209d39SAndroid Build Coastguard Worker  * in the destination buffer. Note that "real" mirroring has
2242*0e209d39SAndroid Build Coastguard Worker  * to be done in a rendering engine by glyph selection
2243*0e209d39SAndroid Build Coastguard Worker  * and that for many "mirrored" characters there are no
2244*0e209d39SAndroid Build Coastguard Worker  * Unicode characters as mirror-image equivalents.
2245*0e209d39SAndroid Build Coastguard Worker  * There are also options to insert or remove Bidi control
2246*0e209d39SAndroid Build Coastguard Worker  * characters.
2247*0e209d39SAndroid Build Coastguard Worker  *
2248*0e209d39SAndroid Build Coastguard Worker  * This function is the implementation for reversing RTL runs as part
2249*0e209d39SAndroid Build Coastguard Worker  * of <code>ubidi_writeReordered()</code>. For detailed descriptions
2250*0e209d39SAndroid Build Coastguard Worker  * of the parameters, see there.
2251*0e209d39SAndroid Build Coastguard Worker  * Since no Bidi controls are inserted here, the output string length
2252*0e209d39SAndroid Build Coastguard Worker  * will never exceed <code>srcLength</code>.
2253*0e209d39SAndroid Build Coastguard Worker  *
2254*0e209d39SAndroid Build Coastguard Worker  * @see ubidi_writeReordered
2255*0e209d39SAndroid Build Coastguard Worker  *
2256*0e209d39SAndroid Build Coastguard Worker  * @param src A pointer to the RTL run text.
2257*0e209d39SAndroid Build Coastguard Worker  *
2258*0e209d39SAndroid Build Coastguard Worker  * @param srcLength The length of the RTL run.
2259*0e209d39SAndroid Build Coastguard Worker  *
2260*0e209d39SAndroid Build Coastguard Worker  * @param dest A pointer to where the reordered text is to be copied.
2261*0e209d39SAndroid Build Coastguard Worker  *             <code>src[srcLength]</code> and <code>dest[destSize]</code>
2262*0e209d39SAndroid Build Coastguard Worker  *             must not overlap.
2263*0e209d39SAndroid Build Coastguard Worker  *
2264*0e209d39SAndroid Build Coastguard Worker  * @param destSize The size of the <code>dest</code> buffer,
2265*0e209d39SAndroid Build Coastguard Worker  *                 in number of UChars.
2266*0e209d39SAndroid Build Coastguard Worker  *                 If the <code>UBIDI_REMOVE_BIDI_CONTROLS</code> option
2267*0e209d39SAndroid Build Coastguard Worker  *                 is set, then the destination length may be less than
2268*0e209d39SAndroid Build Coastguard Worker  *                 <code>srcLength</code>.
2269*0e209d39SAndroid Build Coastguard Worker  *                 If this option is not set, then the destination length
2270*0e209d39SAndroid Build Coastguard Worker  *                 will be exactly <code>srcLength</code>.
2271*0e209d39SAndroid Build Coastguard Worker  *
2272*0e209d39SAndroid Build Coastguard Worker  * @param options A bit set of options for the reordering that control
2273*0e209d39SAndroid Build Coastguard Worker  *                how the reordered text is written.
2274*0e209d39SAndroid Build Coastguard Worker  *                See the <code>options</code> parameter in <code>ubidi_writeReordered()</code>.
2275*0e209d39SAndroid Build Coastguard Worker  *
2276*0e209d39SAndroid Build Coastguard Worker  * @param pErrorCode must be a valid pointer to an error code value.
2277*0e209d39SAndroid Build Coastguard Worker  *
2278*0e209d39SAndroid Build Coastguard Worker  * @return The length of the output string.
2279*0e209d39SAndroid Build Coastguard Worker  * \xrefitem stable "Stable" "Stable List" ICU 2.0
2280*0e209d39SAndroid Build Coastguard Worker  */
2281*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
2282*0e209d39SAndroid Build Coastguard Worker ubidi_writeReverse(const UChar *src, int32_t srcLength,
2283*0e209d39SAndroid Build Coastguard Worker                    UChar *dest, int32_t destSize,
2284*0e209d39SAndroid Build Coastguard Worker                    uint16_t options,
2285*0e209d39SAndroid Build Coastguard Worker                    UErrorCode *pErrorCode) __INTRODUCED_IN(31);
2286*0e209d39SAndroid Build Coastguard Worker 
2287*0e209d39SAndroid Build Coastguard Worker 
2288*0e209d39SAndroid Build Coastguard Worker 
2289*0e209d39SAndroid Build Coastguard Worker /*#define BIDI_SAMPLE_CODE*/
2290*0e209d39SAndroid Build Coastguard Worker /*@}*/
2291*0e209d39SAndroid Build Coastguard Worker 
2292*0e209d39SAndroid Build Coastguard Worker #endif
2293