ICU 60.1  60.1
ubidi.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ******************************************************************************
5 *
6 * Copyright (C) 1999-2013, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 ******************************************************************************
10 * file name: ubidi.h
11 * encoding: UTF-8
12 * tab size: 8 (not used)
13 * indentation:4
14 *
15 * created on: 1999jul27
16 * created by: Markus W. Scherer, updated by Matitiahu Allouche
17 */
18 
19 #ifndef UBIDI_H
20 #define UBIDI_H
21 
22 #include "unicode/utypes.h"
23 #include "unicode/uchar.h"
24 #include "unicode/localpointer.h"
25 
289 /*DOCXX_TAG*/
332 typedef uint8_t UBiDiLevel;
333 
358 #define UBIDI_DEFAULT_LTR 0xfe
359 
385 #define UBIDI_DEFAULT_RTL 0xff
386 
392 #define UBIDI_MAX_EXPLICIT_LEVEL 125
393 
398 #define UBIDI_LEVEL_OVERRIDE 0x80
399 
413 #define UBIDI_MAP_NOWHERE (-1)
414 
458 };
459 
462 
473 struct UBiDi;
474 
476 typedef struct UBiDi UBiDi;
477 
493 U_STABLE UBiDi * U_EXPORT2
494 ubidi_open(void);
495 
530 U_STABLE UBiDi * U_EXPORT2
531 ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
532 
553 U_STABLE void U_EXPORT2
554 ubidi_close(UBiDi *pBiDi);
555 
556 #if U_SHOW_CPLUSPLUS_API
557 
559 
570 
572 
573 #endif
574 
623 U_STABLE void U_EXPORT2
624 ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
625 
642 U_STABLE UBool U_EXPORT2
643 ubidi_isInverse(UBiDi *pBiDi);
644 
665 U_STABLE void U_EXPORT2
666 ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
667 
679 U_STABLE UBool U_EXPORT2
681 
689 typedef enum UBiDiReorderingMode {
723 #ifndef U_HIDE_DEPRECATED_API
724 
729 #endif // U_HIDE_DEPRECATED_API
731 
883 U_STABLE void U_EXPORT2
884 ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode);
885 
896 
904 typedef enum UBiDiReorderingOption {
912 
958 
976 
1025 
1039 U_STABLE void U_EXPORT2
1040 ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
1041 
1050 U_STABLE uint32_t U_EXPORT2
1052 
1137 U_STABLE void U_EXPORT2
1138 ubidi_setContext(UBiDi *pBiDi,
1139  const UChar *prologue, int32_t proLength,
1140  const UChar *epilogue, int32_t epiLength,
1141  UErrorCode *pErrorCode);
1142 
1225 U_STABLE void U_EXPORT2
1226 ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
1227  UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
1228  UErrorCode *pErrorCode);
1229 
1276 U_STABLE void U_EXPORT2
1277 ubidi_setLine(const UBiDi *pParaBiDi,
1278  int32_t start, int32_t limit,
1279  UBiDi *pLineBiDi,
1280  UErrorCode *pErrorCode);
1281 
1297 U_STABLE UBiDiDirection U_EXPORT2
1298 ubidi_getDirection(const UBiDi *pBiDi);
1299 
1327 U_STABLE UBiDiDirection U_EXPORT2
1328 ubidi_getBaseDirection(const UChar *text, int32_t length );
1329 
1341 U_STABLE const UChar * U_EXPORT2
1342 ubidi_getText(const UBiDi *pBiDi);
1343 
1352 U_STABLE int32_t U_EXPORT2
1353 ubidi_getLength(const UBiDi *pBiDi);
1354 
1370 U_STABLE UBiDiLevel U_EXPORT2
1371 ubidi_getParaLevel(const UBiDi *pBiDi);
1372 
1381 U_STABLE int32_t U_EXPORT2
1383 
1418 U_STABLE int32_t U_EXPORT2
1419 ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
1420  int32_t *pParaLimit, UBiDiLevel *pParaLevel,
1421  UErrorCode *pErrorCode);
1422 
1450 U_STABLE void U_EXPORT2
1451 ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
1452  int32_t *pParaStart, int32_t *pParaLimit,
1453  UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);
1454 
1470 U_STABLE UBiDiLevel U_EXPORT2
1471 ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
1472 
1491 U_STABLE const UBiDiLevel * U_EXPORT2
1492 ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
1493 
1518 U_STABLE void U_EXPORT2
1519 ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
1520  int32_t *pLogicalLimit, UBiDiLevel *pLevel);
1521 
1537 U_STABLE int32_t U_EXPORT2
1538 ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
1539 
1596 U_STABLE UBiDiDirection U_EXPORT2
1597 ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
1598  int32_t *pLogicalStart, int32_t *pLength);
1599 
1637 U_STABLE int32_t U_EXPORT2
1638 ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);
1639 
1672 U_STABLE int32_t U_EXPORT2
1673 ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);
1674 
1715 U_STABLE void U_EXPORT2
1716 ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1717 
1751 U_STABLE void U_EXPORT2
1752 ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1753 
1774 U_STABLE void U_EXPORT2
1775 ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1776 
1797 U_STABLE void U_EXPORT2
1798 ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1799 
1832 U_STABLE void U_EXPORT2
1833 ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
1834 
1844 #define UBIDI_KEEP_BASE_COMBINING 1
1845 
1854 #define UBIDI_DO_MIRRORING 2
1855 
1868 #define UBIDI_INSERT_LRM_FOR_NUMERIC 4
1869 
1881 #define UBIDI_REMOVE_BIDI_CONTROLS 8
1882 
1897 #define UBIDI_OUTPUT_REVERSE 16
1898 
1937 U_STABLE int32_t U_EXPORT2
1938 ubidi_getProcessedLength(const UBiDi *pBiDi);
1939 
1967 U_STABLE int32_t U_EXPORT2
1968 ubidi_getResultLength(const UBiDi *pBiDi);
1969 
1971 
1972 #ifndef U_HIDE_DEPRECATED_API
1973 
1982 #define U_BIDI_CLASS_DEFAULT U_CHAR_DIRECTION_COUNT
1983 #endif // U_HIDE_DEPRECATED_API
1984 
2005 typedef UCharDirection U_CALLCONV
2006 UBiDiClassCallback(const void *context, UChar32 c);
2007 
2009 
2025 U_STABLE UCharDirection U_EXPORT2
2027 
2055 U_STABLE void U_EXPORT2
2057  const void *newContext, UBiDiClassCallback **oldFn,
2058  const void **oldContext, UErrorCode *pErrorCode);
2059 
2072 U_STABLE void U_EXPORT2
2073 ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);
2074 
2140 U_STABLE int32_t U_EXPORT2
2142  UChar *dest, int32_t destSize,
2143  uint16_t options,
2144  UErrorCode *pErrorCode);
2145 
2192 U_STABLE int32_t U_EXPORT2
2193 ubidi_writeReverse(const UChar *src, int32_t srcLength,
2194  UChar *dest, int32_t destSize,
2195  uint16_t options,
2196  UErrorCode *pErrorCode);
2197 
2198 /*#define BIDI_SAMPLE_CODE*/
2201 #endif
Logical to Visual algorithm which handles numbers in a way which mimicks the behavior of Windows XP...
Definition: ubidi.h:697
UBiDi * ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode)
Allocate a UBiDi structure with preallocated memory for internal structures.
Reorder runs only to transform a Logical LTR string to the Logical RTL string with the same display...
Definition: ubidi.h:709
void ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode)
Get a logical-to-visual index map (array) for the characters in the UBiDi (paragraph or line) object...
void ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context)
Get the current callback function used for Bidi class determination.
int32_t ubidi_writeReverse(const UChar *src, int32_t srcLength, UChar *dest, int32_t destSize, uint16_t options, UErrorCode *pErrorCode)
Reverse a Right-To-Left run of Unicode text.
void ubidi_setLine(const UBiDi *pParaBiDi, int32_t start, int32_t limit, UBiDi *pLineBiDi, UErrorCode *pErrorCode)
ubidi_setLine() sets a UBiDi to contain the reordering information, especially the resolved levels...
option bit for ubidi_setReorderingOptions: process the output as part of a stream to be continued ...
Definition: ubidi.h:1023
void ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex, int32_t *pParaStart, int32_t *pParaLimit, UBiDiLevel *pParaLevel, UErrorCode *pErrorCode)
Get a paragraph, given the index of this paragraph.
void ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions)
Specify which of the reordering options should be applied during Bidi transformations.
int32_t ubidi_getLength(const UBiDi *pBiDi)
Get the length of the text.
void ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition, int32_t *pLogicalLimit, UBiDiLevel *pLevel)
Get a logical run.
UBiDiDirection ubidi_getBaseDirection(const UChar *text, int32_t length)
Gets the base direction of the text provided according to the Unicode Bidirectional Algorithm...
UBiDiLevel ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex)
Get the level for one character.
Number of values for reordering mode.
Definition: ubidi.h:728
UCharDirection UBiDiClassCallback(const void *context, UChar32 c)
Callback type declaration for overriding default Bidi class values with custom ones.
Definition: ubidi.h:2006
option bit for ubidi_setReorderingOptions: remove Bidi control characters
Definition: ubidi.h:975
UCharDirection ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c)
Retrieve the Bidi class for a given code point.
UBool ubidi_isOrderParagraphsLTR(UBiDi *pBiDi)
Is this Bidi object set to allocate level 0 to block separators so that successive paragraphs progres...
Visual to Logical algorithm which handles numbers like L (same algorithm as selected by ubidi_setInve...
Definition: ubidi.h:714
UCharDirection
This specifies the language directional property of a character set.
Definition: uchar.h:862
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition: platform.h:848
void ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR)
Specify whether block separators must be allocated level zero, so that successive paragraphs will pro...
void ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode)
Modify the operation of the Bidi algorithm such that it implements some variant to the basic Bidi alg...
uint8_t UBiDiLevel
UBiDiLevel is the type of the level values in this Bidi implementation.
Definition: ubidi.h:332
Inverse Bidi (Visual to Logical) algorithm for the UBIDI_REORDER_NUMBERS_SPECIAL Bidi algorithm...
Definition: ubidi.h:722
Mixed-directional text.
Definition: ubidi.h:450
UBiDi * ubidi_open(void)
Allocate a UBiDi structure.
int32_t ubidi_getProcessedLength(const UBiDi *pBiDi)
Get the length of the source text processed by the last call to ubidi_setPara().
UBiDiReorderingOption
UBiDiReorderingOption values indicate which options are specified to affect the Bidi algorithm...
Definition: ubidi.h:904
void ubidi_setContext(UBiDi *pBiDi, const UChar *prologue, int32_t proLength, const UChar *epilogue, int32_t epiLength, UErrorCode *pErrorCode)
Set the context before a call to ubidi_setPara().
option value for ubidi_setReorderingOptions: disable all the options which can be set with this funct...
Definition: ubidi.h:911
int32_t ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart, int32_t *pParaLimit, UBiDiLevel *pParaLevel, UErrorCode *pErrorCode)
Get a paragraph, given a position within the text.
UBiDiDirection
UBiDiDirection values indicate the text direction.
Definition: ubidi.h:419
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition: umachine.h:84
void ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode)
Get a visual-to-logical index map (array) for the characters in the UBiDi (paragraph or line) object...
UBiDiDirection ubidi_getDirection(const UBiDi *pBiDi)
Get the directionality of the text.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
int32_t ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode)
Get the logical text position from a visual position.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:487
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
UBiDiReorderingMode ubidi_getReorderingMode(UBiDi *pBiDi)
What is the requested reordering mode for a given Bidi object?
int32_t ubidi_getResultLength(const UBiDi *pBiDi)
Get the length of the reordered text resulting from the last call to ubidi_setPara().
Regular Logical to Visual Bidi algorithm according to Unicode.
Definition: ubidi.h:693
const UBiDiLevel * ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get an array of levels for each character.
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:396
void ubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn, const void *newContext, UBiDiClassCallback **oldFn, const void **oldContext, UErrorCode *pErrorCode)
Set the callback function and callback data used by the UBA implementation for Bidi class determinati...
void ubidi_close(UBiDi *pBiDi)
ubidi_close() must be called to free the memory associated with a UBiDi object.
void ubidi_setInverse(UBiDi *pBiDi, UBool isInverse)
Modify the operation of the Bidi algorithm such that it approximates an "inverse Bidi" algorithm...
UBiDiDirection ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex, int32_t *pLogicalStart, int32_t *pLength)
Get one run's logical start, length, and directionality, which can be 0 for LTR or 1 for RTL...
UBiDiLevel ubidi_getParaLevel(const UBiDi *pBiDi)
Get the paragraph level of the text.
option bit for ubidi_setReorderingOptions: insert Bidi marks (LRM or RLM) when needed to ensure corre...
Definition: ubidi.h:957
int32_t ubidi_countParagraphs(UBiDi *pBiDi)
Get the number of paragraphs.
UBool ubidi_isInverse(UBiDi *pBiDi)
Is this Bidi object set to perform the inverse Bidi algorithm?
C API: Unicode Properties.
const UChar * ubidi_getText(const UBiDi *pBiDi)
Get the pointer to the text.
void ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap)
This is a convenience function that does not use a UBiDi object.
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:349
Left-to-right text.
Definition: ubidi.h:431
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:85
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
Visual to Logical algorithm equivalent to the regular Logical to Visual algorithm.
Definition: ubidi.h:718
uint32_t ubidi_getReorderingOptions(UBiDi *pBiDi)
What are the reordering options applied to a given Bidi object?
int32_t ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get the number of runs.
int32_t ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode)
Get the visual position from a logical text position.
struct UBiDi UBiDi
Definition: ubidi.h:476
int32_t ubidi_writeReordered(UBiDi *pBiDi, UChar *dest, int32_t destSize, uint16_t options, UErrorCode *pErrorCode)
Take a UBiDi object containing the reordering information for a piece of text (one or more paragraphs...
void ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length, UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels, UErrorCode *pErrorCode)
Perform the Unicode Bidi algorithm.
void ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap)
This is a convenience function that does not use a UBiDi object.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
Logical to Visual algorithm grouping numbers with adjacent R characters (reversible algorithm)...
Definition: ubidi.h:701
"Smart pointer" class, closes a UBiDi via ubidi_close().
No strongly directional text.
Definition: ubidi.h:457
void ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length)
Invert an index map.
Basic definitions for ICU, for both C and C++ APIs.
UBiDiReorderingMode
UBiDiReorderingMode values indicate which variant of the Bidi algorithm to use.
Definition: ubidi.h:689
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:111
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236
Right-to-left text.
Definition: ubidi.h:443