ICU 68.1  68.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 
25 #if U_SHOW_CPLUSPLUS_API
26 #include "unicode/localpointer.h"
27 #endif // U_SHOW_CPLUSPLUS_API
28 
292 /*DOCXX_TAG*/
339 typedef uint8_t UBiDiLevel;
340 
365 #define UBIDI_DEFAULT_LTR 0xfe
366 
392 #define UBIDI_DEFAULT_RTL 0xff
393 
401 #define UBIDI_MAX_EXPLICIT_LEVEL 125
402 
407 #define UBIDI_LEVEL_OVERRIDE 0x80
408 
422 #define UBIDI_MAP_NOWHERE (-1)
423 
467 };
468 
470 typedef enum UBiDiDirection UBiDiDirection;
471 
482 struct UBiDi;
483 
485 typedef struct UBiDi UBiDi;
486 
502 U_CAPI UBiDi * U_EXPORT2
504 
539 U_CAPI UBiDi * U_EXPORT2
540 ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
541 
562 U_CAPI void U_EXPORT2
564 
565 #if U_SHOW_CPLUSPLUS_API
566 
567 U_NAMESPACE_BEGIN
568 
579 
580 U_NAMESPACE_END
581 
582 #endif
583 
632 U_CAPI void U_EXPORT2
633 ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
634 
651 U_CAPI UBool U_EXPORT2
653 
674 U_CAPI void U_EXPORT2
675 ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
676 
688 U_CAPI UBool U_EXPORT2
690 
698 typedef enum UBiDiReorderingMode {
732 #ifndef U_HIDE_DEPRECATED_API
733 
738 #endif // U_HIDE_DEPRECATED_API
740 
892 U_CAPI void U_EXPORT2
894 
903 U_CAPI UBiDiReorderingMode U_EXPORT2
905 
913 typedef enum UBiDiReorderingOption {
921 
967 
985 
1034 
1048 U_CAPI void U_EXPORT2
1049 ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
1050 
1059 U_CAPI uint32_t U_EXPORT2
1061 
1146 U_CAPI void U_EXPORT2
1148  const UChar *prologue, int32_t proLength,
1149  const UChar *epilogue, int32_t epiLength,
1150  UErrorCode *pErrorCode);
1151 
1234 U_CAPI void U_EXPORT2
1235 ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
1236  UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
1237  UErrorCode *pErrorCode);
1238 
1285 U_CAPI void U_EXPORT2
1286 ubidi_setLine(const UBiDi *pParaBiDi,
1287  int32_t start, int32_t limit,
1288  UBiDi *pLineBiDi,
1289  UErrorCode *pErrorCode);
1290 
1306 U_CAPI UBiDiDirection U_EXPORT2
1308 
1336 U_CAPI UBiDiDirection U_EXPORT2
1337 ubidi_getBaseDirection(const UChar *text, int32_t length );
1338 
1350 U_CAPI const UChar * U_EXPORT2
1351 ubidi_getText(const UBiDi *pBiDi);
1352 
1361 U_CAPI int32_t U_EXPORT2
1362 ubidi_getLength(const UBiDi *pBiDi);
1363 
1379 U_CAPI UBiDiLevel U_EXPORT2
1381 
1390 U_CAPI int32_t U_EXPORT2
1392 
1427 U_CAPI int32_t U_EXPORT2
1428 ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
1429  int32_t *pParaLimit, UBiDiLevel *pParaLevel,
1430  UErrorCode *pErrorCode);
1431 
1459 U_CAPI void U_EXPORT2
1460 ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
1461  int32_t *pParaStart, int32_t *pParaLimit,
1462  UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);
1463 
1479 U_CAPI UBiDiLevel U_EXPORT2
1480 ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
1481 
1500 U_CAPI const UBiDiLevel * U_EXPORT2
1501 ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
1502 
1527 U_CAPI void U_EXPORT2
1528 ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
1529  int32_t *pLogicalLimit, UBiDiLevel *pLevel);
1530 
1546 U_CAPI int32_t U_EXPORT2
1547 ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
1548 
1605 U_CAPI UBiDiDirection U_EXPORT2
1606 ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
1607  int32_t *pLogicalStart, int32_t *pLength);
1608 
1646 U_CAPI int32_t U_EXPORT2
1647 ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);
1648 
1681 U_CAPI int32_t U_EXPORT2
1682 ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);
1683 
1724 U_CAPI void U_EXPORT2
1725 ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1726 
1760 U_CAPI void U_EXPORT2
1761 ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1762 
1783 U_CAPI void U_EXPORT2
1784 ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1785 
1806 U_CAPI void U_EXPORT2
1807 ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1808 
1841 U_CAPI void U_EXPORT2
1842 ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
1843 
1853 #define UBIDI_KEEP_BASE_COMBINING 1
1863 #define UBIDI_DO_MIRRORING 2
1877 #define UBIDI_INSERT_LRM_FOR_NUMERIC 4
1890 #define UBIDI_REMOVE_BIDI_CONTROLS 8
1906 #define UBIDI_OUTPUT_REVERSE 16
1946 U_CAPI int32_t U_EXPORT2
1948 
1976 U_CAPI int32_t U_EXPORT2
1978 
1980 
1981 #ifndef U_HIDE_DEPRECATED_API
1982 
1991 #define U_BIDI_CLASS_DEFAULT U_CHAR_DIRECTION_COUNT
1992 #endif // U_HIDE_DEPRECATED_API
1993 
2014 typedef UCharDirection U_CALLCONV
2015 UBiDiClassCallback(const void *context, UChar32 c);
2016 
2018 
2034 U_CAPI UCharDirection U_EXPORT2
2036 
2064 U_CAPI void U_EXPORT2
2066  const void *newContext, UBiDiClassCallback **oldFn,
2067  const void **oldContext, UErrorCode *pErrorCode);
2068 
2081 U_CAPI void U_EXPORT2
2082 ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);
2083 
2149 U_CAPI int32_t U_EXPORT2
2151  UChar *dest, int32_t destSize,
2152  uint16_t options,
2153  UErrorCode *pErrorCode);
2154 
2201 U_CAPI int32_t U_EXPORT2
2202 ubidi_writeReverse(const UChar *src, int32_t srcLength,
2203  UChar *dest, int32_t destSize,
2204  uint16_t options,
2205  UErrorCode *pErrorCode);
2206 
2207 /*#define BIDI_SAMPLE_CODE*/
2210 #endif
ubidi_getDirection
U_CAPI UBiDiDirection ubidi_getDirection(const UBiDi *pBiDi)
Get the directionality of the text.
ubidi_getLogicalMap
U_CAPI 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.
UBiDiReorderingOption
UBiDiReorderingOption
UBiDiReorderingOption values indicate which options are specified to affect the Bidi algorithm.
Definition: ubidi.h:913
ubidi_setInverse
U_CAPI void ubidi_setInverse(UBiDi *pBiDi, UBool isInverse)
Modify the operation of the Bidi algorithm such that it approximates an "inverse Bidi" algorithm.
ubidi_setReorderingMode
U_CAPI 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...
ubidi_getParagraphByIndex
U_CAPI 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.
ubidi_getVisualMap
U_CAPI 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.
UBiDiReorderingMode
UBiDiReorderingMode
UBiDiReorderingMode values indicate which variant of the Bidi algorithm to use.
Definition: ubidi.h:698
ubidi_getLogicalIndex
U_CAPI int32_t ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode)
Get the logical text position from a visual position.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UBiDiLevel
uint8_t UBiDiLevel
UBiDiLevel is the type of the level values in this Bidi implementation.
Definition: ubidi.h:339
ubidi_setLine
U_CAPI 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,...
UBIDI_REORDER_INVERSE_NUMBERS_AS_L
@ UBIDI_REORDER_INVERSE_NUMBERS_AS_L
Visual to Logical algorithm which handles numbers like L (same algorithm as selected by ubidi_setInve...
Definition: ubidi.h:723
ubidi_getLevels
U_CAPI const UBiDiLevel * ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get an array of levels for each character.
ubidi_getReorderingMode
U_CAPI UBiDiReorderingMode ubidi_getReorderingMode(UBiDi *pBiDi)
What is the requested reordering mode for a given Bidi object?
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
UBIDI_OPTION_INSERT_MARKS
@ UBIDI_OPTION_INSERT_MARKS
option bit for ubidi_setReorderingOptions: insert Bidi marks (LRM or RLM) when needed to ensure corre...
Definition: ubidi.h:966
U_CALLCONV
#define U_CALLCONV
Definition: platform.h:870
ubidi_setClassCallback
U_CAPI 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...
ubidi_getParagraph
U_CAPI 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.
ubidi_getClassCallback
U_CAPI void ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context)
Get the current callback function used for Bidi class determination.
UBIDI_OPTION_DEFAULT
@ UBIDI_OPTION_DEFAULT
option value for ubidi_setReorderingOptions: disable all the options which can be set with this funct...
Definition: ubidi.h:920
UBIDI_REORDER_GROUP_NUMBERS_WITH_R
@ UBIDI_REORDER_GROUP_NUMBERS_WITH_R
Logical to Visual algorithm grouping numbers with adjacent R characters (reversible algorithm).
Definition: ubidi.h:710
UBIDI_NEUTRAL
@ UBIDI_NEUTRAL
No strongly directional text.
Definition: ubidi.h:466
ubidi_reorderLogical
U_CAPI void ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap)
This is a convenience function that does not use a UBiDi object.
UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL
@ UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL
Inverse Bidi (Visual to Logical) algorithm for the UBIDI_REORDER_NUMBERS_SPECIAL Bidi algorithm.
Definition: ubidi.h:731
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:467
ubidi_isOrderParagraphsLTR
U_CAPI UBool ubidi_isOrderParagraphsLTR(UBiDi *pBiDi)
Is this Bidi object set to allocate level 0 to block separators so that successive paragraphs progres...
ubidi_isInverse
U_CAPI UBool ubidi_isInverse(UBiDi *pBiDi)
Is this Bidi object set to perform the inverse Bidi algorithm?
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
UCharDirection
UCharDirection
This specifies the language directional property of a character set.
Definition: uchar.h:921
UBIDI_REORDER_NUMBERS_SPECIAL
@ UBIDI_REORDER_NUMBERS_SPECIAL
Logical to Visual algorithm which handles numbers in a way which mimics the behavior of Windows XP.
Definition: ubidi.h:706
ubidi_writeReordered
U_CAPI 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...
UBIDI_RTL
@ UBIDI_RTL
Right-to-left text.
Definition: ubidi.h:452
ubidi_getVisualIndex
U_CAPI int32_t ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode)
Get the visual position from a logical text position.
UBIDI_OPTION_STREAMING
@ UBIDI_OPTION_STREAMING
option bit for ubidi_setReorderingOptions: process the output as part of a stream to be continued
Definition: ubidi.h:1032
U_CDECL_END
#define U_CDECL_END
Definition: umachine.h:86
U_CDECL_BEGIN
#define U_CDECL_BEGIN
Definition: umachine.h:85
ubidi_getLevelAt
U_CAPI UBiDiLevel ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex)
Get the level for one character.
ubidi_getParaLevel
U_CAPI UBiDiLevel ubidi_getParaLevel(const UBiDi *pBiDi)
Get the paragraph level of the text.
UBIDI_LTR
@ UBIDI_LTR
Left-to-right text.
Definition: ubidi.h:440
ubidi_countParagraphs
U_CAPI int32_t ubidi_countParagraphs(UBiDi *pBiDi)
Get the number of paragraphs.
ubidi_getVisualRun
U_CAPI 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.
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
Definition: localpointer.h:550
UBiDi
struct UBiDi UBiDi
Definition: ubidi.h:485
ubidi_getProcessedLength
U_CAPI int32_t ubidi_getProcessedLength(const UBiDi *pBiDi)
Get the length of the source text processed by the last call to ubidi_setPara().
UBIDI_REORDER_DEFAULT
@ UBIDI_REORDER_DEFAULT
Regular Logical to Visual Bidi algorithm according to Unicode.
Definition: ubidi.h:702
UBiDiDirection
UBiDiDirection
UBiDiDirection values indicate the text direction.
Definition: ubidi.h:428
ubidi_getText
U_CAPI const UChar * ubidi_getText(const UBiDi *pBiDi)
Get the pointer to the text.
ubidi_setPara
U_CAPI void ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length, UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels, UErrorCode *pErrorCode)
Perform the Unicode Bidi algorithm.
LocalUBiDiPointer
UBiDiClassCallback
UCharDirection UBiDiClassCallback(const void *context, UChar32 c)
Callback type declaration for overriding default Bidi class values with custom ones.
Definition: ubidi.h:2015
ubidi_close
U_CAPI void ubidi_close(UBiDi *pBiDi)
ubidi_close() must be called to free the memory associated with a UBiDi object.
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
ubidi_getLogicalRun
U_CAPI void ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition, int32_t *pLogicalLimit, UBiDiLevel *pLevel)
Get a logical run.
ubidi_getCustomizedClass
U_CAPI UCharDirection ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c)
Retrieve the Bidi class for a given code point.
UBIDI_REORDER_INVERSE_LIKE_DIRECT
@ UBIDI_REORDER_INVERSE_LIKE_DIRECT
Visual to Logical algorithm equivalent to the regular Logical to Visual algorithm.
Definition: ubidi.h:727
ubidi_getBaseDirection
U_CAPI UBiDiDirection ubidi_getBaseDirection(const UChar *text, int32_t length)
Gets the base direction of the text provided according to the Unicode Bidirectional Algorithm.
UBIDI_MIXED
@ UBIDI_MIXED
Mixed-directional text.
Definition: ubidi.h:459
ubidi_openSized
U_CAPI UBiDi * ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode)
Allocate a UBiDi structure with preallocated memory for internal structures.
ubidi_orderParagraphsLTR
U_CAPI void ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR)
Specify whether block separators must be allocated level zero, so that successive paragraphs will pro...
ubidi_setContext
U_CAPI 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().
ubidi_invertMap
U_CAPI void ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length)
Invert an index map.
uchar.h
C API: Unicode Properties.
ubidi_open
U_CAPI UBiDi * ubidi_open(void)
Allocate a UBiDi structure.
ubidi_setReorderingOptions
U_CAPI void ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions)
Specify which of the reordering options should be applied during Bidi transformations.
ubidi_getReorderingOptions
U_CAPI uint32_t ubidi_getReorderingOptions(UBiDi *pBiDi)
What are the reordering options applied to a given Bidi object?
UChar
char16_t UChar
Definition: umachine.h:418
UBIDI_REORDER_COUNT
@ UBIDI_REORDER_COUNT
Number of values for reordering mode.
Definition: ubidi.h:737
UBIDI_REORDER_RUNS_ONLY
@ UBIDI_REORDER_RUNS_ONLY
Reorder runs only to transform a Logical LTR string to the Logical RTL string with the same display,...
Definition: ubidi.h:718
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
ubidi_countRuns
U_CAPI int32_t ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get the number of runs.
ubidi_reorderVisual
U_CAPI void ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap)
This is a convenience function that does not use a UBiDi object.
UBIDI_OPTION_REMOVE_CONTROLS
@ UBIDI_OPTION_REMOVE_CONTROLS
option bit for ubidi_setReorderingOptions: remove Bidi control characters
Definition: ubidi.h:984
ubidi_getResultLength
U_CAPI int32_t ubidi_getResultLength(const UBiDi *pBiDi)
Get the length of the reordered text resulting from the last call to ubidi_setPara().
ubidi_writeReverse
U_CAPI 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.
ubidi_getLength
U_CAPI int32_t ubidi_getLength(const UBiDi *pBiDi)
Get the length of the text.