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