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