ICU 58.2 58.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

ubidi.h
Go to the documentation of this file.
1 // Copyright (C) 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: US-ASCII
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
419 enum UBiDiDirection {
431 UBIDI_LTR,
443 UBIDI_RTL,
450 UBIDI_MIXED,
457 UBIDI_NEUTRAL
458 };
459
461 typedef enum UBiDiDirection UBiDiDirection;
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
558 U_NAMESPACE_BEGIN
559
569 U_DEFINE_LOCAL_OPEN_POINTER(LocalUBiDiPointer, UBiDi, ubidi_close);
570
571 U_NAMESPACE_END
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
680 ubidi_isOrderParagraphsLTR(UBiDi *pBiDi);
681
689 typedef enum UBiDiReorderingMode {
693 UBIDI_REORDER_DEFAULT = 0,
697 UBIDI_REORDER_NUMBERS_SPECIAL,
701 UBIDI_REORDER_GROUP_NUMBERS_WITH_R,
709 UBIDI_REORDER_RUNS_ONLY,
714 UBIDI_REORDER_INVERSE_NUMBERS_AS_L,
718 UBIDI_REORDER_INVERSE_LIKE_DIRECT,
722 UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL,
723 #ifndef U_HIDE_DEPRECATED_API
724
728 UBIDI_REORDER_COUNT
729 #endif // U_HIDE_DEPRECATED_API
730 } UBiDiReorderingMode;
731
883 U_STABLE void U_EXPORT2
884 ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode);
885
894 U_STABLE UBiDiReorderingMode U_EXPORT2
895 ubidi_getReorderingMode(UBiDi *pBiDi);
896
904 typedef enum UBiDiReorderingOption {
911 UBIDI_OPTION_DEFAULT = 0,
912
957 UBIDI_OPTION_INSERT_MARKS = 1,
958
975 UBIDI_OPTION_REMOVE_CONTROLS = 2,
976
1023 UBIDI_OPTION_STREAMING = 4
1024 } UBiDiReorderingOption;
1025
1039 U_STABLE void U_EXPORT2
1040 ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
1041
1050 U_STABLE uint32_t U_EXPORT2
1051 ubidi_getReorderingOptions(UBiDi *pBiDi);
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
1222 U_STABLE void U_EXPORT2
1223 ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
1224 UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
1225 UErrorCode *pErrorCode);
1226
1273 U_STABLE void U_EXPORT2
1274 ubidi_setLine(const UBiDi *pParaBiDi,
1275 int32_t start, int32_t limit,
1276 UBiDi *pLineBiDi,
1277 UErrorCode *pErrorCode);
1278
1294 U_STABLE UBiDiDirection U_EXPORT2
1295 ubidi_getDirection(const UBiDi *pBiDi);
1296
1324 U_STABLE UBiDiDirection U_EXPORT2
1325 ubidi_getBaseDirection(const UChar *text, int32_t length );
1326
1338 U_STABLE const UChar * U_EXPORT2
1339 ubidi_getText(const UBiDi *pBiDi);
1340
1349 U_STABLE int32_t U_EXPORT2
1350 ubidi_getLength(const UBiDi *pBiDi);
1351
1367 U_STABLE UBiDiLevel U_EXPORT2
1368 ubidi_getParaLevel(const UBiDi *pBiDi);
1369
1378 U_STABLE int32_t U_EXPORT2
1379 ubidi_countParagraphs(UBiDi *pBiDi);
1380
1415 U_STABLE int32_t U_EXPORT2
1416 ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
1417 int32_t *pParaLimit, UBiDiLevel *pParaLevel,
1418 UErrorCode *pErrorCode);
1419
1447 U_STABLE void U_EXPORT2
1448 ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
1449 int32_t *pParaStart, int32_t *pParaLimit,
1450 UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);
1451
1467 U_STABLE UBiDiLevel U_EXPORT2
1468 ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
1469
1488 U_STABLE const UBiDiLevel * U_EXPORT2
1489 ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
1490
1515 U_STABLE void U_EXPORT2
1516 ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
1517 int32_t *pLogicalLimit, UBiDiLevel *pLevel);
1518
1534 U_STABLE int32_t U_EXPORT2
1535 ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
1536
1593 U_STABLE UBiDiDirection U_EXPORT2
1594 ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
1595 int32_t *pLogicalStart, int32_t *pLength);
1596
1634 U_STABLE int32_t U_EXPORT2
1635 ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);
1636
1669 U_STABLE int32_t U_EXPORT2
1670 ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);
1671
1712 U_STABLE void U_EXPORT2
1713 ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1714
1748 U_STABLE void U_EXPORT2
1749 ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1750
1771 U_STABLE void U_EXPORT2
1772 ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1773
1794 U_STABLE void U_EXPORT2
1795 ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1796
1829 U_STABLE void U_EXPORT2
1830 ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
1831
1841 #define UBIDI_KEEP_BASE_COMBINING 1
1842
1851 #define UBIDI_DO_MIRRORING 2
1852
1865 #define UBIDI_INSERT_LRM_FOR_NUMERIC 4
1866
1878 #define UBIDI_REMOVE_BIDI_CONTROLS 8
1879
1894 #define UBIDI_OUTPUT_REVERSE 16
1895
1934 U_STABLE int32_t U_EXPORT2
1935 ubidi_getProcessedLength(const UBiDi *pBiDi);
1936
1964 U_STABLE int32_t U_EXPORT2
1965 ubidi_getResultLength(const UBiDi *pBiDi);
1966
1967 U_CDECL_BEGIN
1968
1969 #ifndef U_HIDE_DEPRECATED_API
1970
1979 #define U_BIDI_CLASS_DEFAULT U_CHAR_DIRECTION_COUNT
1980 #endif // U_HIDE_DEPRECATED_API
1981
2002 typedef UCharDirection U_CALLCONV
2003 UBiDiClassCallback(const void *context, UChar32 c);
2004
2005 U_CDECL_END
2006
2022 U_STABLE UCharDirection U_EXPORT2
2023 ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c);
2024
2052 U_STABLE void U_EXPORT2
2053 ubidi_setClassCallback(UBiDi *pBiDi, UBiDiClassCallback *newFn,
2054 const void *newContext, UBiDiClassCallback **oldFn,
2055 const void **oldContext, UErrorCode *pErrorCode);
2056
2069 U_STABLE void U_EXPORT2
2070 ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);
2071
2137 U_STABLE int32_t U_EXPORT2
2138 ubidi_writeReordered(UBiDi *pBiDi,
2139 UChar *dest, int32_t destSize,
2140 uint16_t options,
2141 UErrorCode *pErrorCode);
2142
2189 U_STABLE int32_t U_EXPORT2
2190 ubidi_writeReverse(const UChar *src, int32_t srcLength,
2191 UChar *dest, int32_t destSize,
2192 uint16_t options,
2193 UErrorCode *pErrorCode);
2194
2195 /*#define BIDI_SAMPLE_CODE*/
2198 #endif
UBIDI_REORDER_NUMBERS_SPECIAL
Logical to Visual algorithm which handles numbers in a way which mimicks the behavior of Windows XP...
Definition: ubidi.h:697
ubidi_openSized
UBiDi * ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode)
Allocate a UBiDi structure with preallocated memory for internal structures.
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:709
ubidi_getLogicalMap
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...
ubidi_getClassCallback
void ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context)
Get the current callback function used for Bidi class determination.
ubidi_writeReverse
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_setLine
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_OPTION_STREAMING
option bit for ubidi_setReorderingOptions: process the output as part of a stream to be continued ...
Definition: ubidi.h:1023
ubidi_getParagraphByIndex
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_setReorderingOptions
void ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions)
Specify which of the reordering options should be applied during Bidi transformations.
ubidi_getLength
int32_t ubidi_getLength(const UBiDi *pBiDi)
Get the length of the text.
ubidi_getLogicalRun
void ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition, int32_t *pLogicalLimit, UBiDiLevel *pLevel)
Get a logical run.
ubidi_getBaseDirection
UBiDiDirection ubidi_getBaseDirection(const UChar *text, int32_t length)
Gets the base direction of the text provided according to the Unicode Bidirectional Algorithm...
ubidi_getLevelAt
UBiDiLevel ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex)
Get the level for one character.
UBIDI_REORDER_COUNT
Number of values for reordering mode.
Definition: ubidi.h:728
UBiDiClassCallback
UCharDirection UBiDiClassCallback(const void *context, UChar32 c)
Callback type declaration for overriding default Bidi class values with custom ones.
Definition: ubidi.h:2003
UBIDI_OPTION_REMOVE_CONTROLS
option bit for ubidi_setReorderingOptions: remove Bidi control characters
Definition: ubidi.h:975
ubidi_getCustomizedClass
UCharDirection ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c)
Retrieve the Bidi class for a given code point.
ubidi_isOrderParagraphsLTR
UBool ubidi_isOrderParagraphsLTR(UBiDi *pBiDi)
Is this Bidi object set to allocate level 0 to block separators so that successive paragraphs progres...
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:714
UCharDirection
UCharDirection
This specifies the language directional property of a character set.
Definition: uchar.h:845
U_CALLCONV
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition: platform.h:857
ubidi_orderParagraphsLTR
void ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR)
Specify whether block separators must be allocated level zero, so that successive paragraphs will pro...
ubidi_setReorderingMode
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...
UBiDiLevel
uint8_t UBiDiLevel
UBiDiLevel is the type of the level values in this Bidi implementation.
Definition: ubidi.h:332
UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL
Inverse Bidi (Visual to Logical) algorithm for the UBIDI_REORDER_NUMBERS_SPECIAL Bidi algorithm...
Definition: ubidi.h:722
UBIDI_MIXED
Mixed-directional text.
Definition: ubidi.h:450
ubidi_open
UBiDi * ubidi_open(void)
Allocate a UBiDi structure.
ubidi_getProcessedLength
int32_t ubidi_getProcessedLength(const UBiDi *pBiDi)
Get the length of the source text processed by the last call to ubidi_setPara().
UBiDiReorderingOption
UBiDiReorderingOption
UBiDiReorderingOption values indicate which options are specified to affect the Bidi algorithm...
Definition: ubidi.h:904
ubidi_setContext
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_OPTION_DEFAULT
option value for ubidi_setReorderingOptions: disable all the options which can be set with this funct...
Definition: ubidi.h:911
ubidi_getParagraph
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
UBiDiDirection values indicate the text direction.
Definition: ubidi.h:419
U_CDECL_BEGIN
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition: umachine.h:107
ubidi_getVisualMap
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...
ubidi_getDirection
UBiDiDirection ubidi_getDirection(const UBiDi *pBiDi)
Get the directionality of the text.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
ubidi_getLogicalIndex
int32_t ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode)
Get the logical text position from a visual position.
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:530
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
ubidi_getReorderingMode
UBiDiReorderingMode ubidi_getReorderingMode(UBiDi *pBiDi)
What is the requested reordering mode for a given Bidi object?
ubidi_getResultLength
int32_t ubidi_getResultLength(const UBiDi *pBiDi)
Get the length of the reordered text resulting from the last call to ubidi_setPara().
UBIDI_REORDER_DEFAULT
Regular Logical to Visual Bidi algorithm according to Unicode.
Definition: ubidi.h:693
ubidi_getLevels
const UBiDiLevel * ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get an array of levels for each character.
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:357
ubidi_setClassCallback
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_close
void ubidi_close(UBiDi *pBiDi)
ubidi_close() must be called to free the memory associated with a UBiDi object.
ubidi_setInverse
void ubidi_setInverse(UBiDi *pBiDi, UBool isInverse)
Modify the operation of the Bidi algorithm such that it approximates an "inverse Bidi" algorithm...
ubidi_getVisualRun
UBiDiDirection ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex, int32_t *pLogicalStart, int32_t *pLength)
Get one run&#39;s logical start, length, and directionality, which can be 0 for LTR or 1 for RTL...
ubidi_getParaLevel
UBiDiLevel ubidi_getParaLevel(const UBiDi *pBiDi)
Get the paragraph level of the text.
UBIDI_OPTION_INSERT_MARKS
option bit for ubidi_setReorderingOptions: insert Bidi marks (LRM or RLM) when needed to ensure corre...
Definition: ubidi.h:957
ubidi_countParagraphs
int32_t ubidi_countParagraphs(UBiDi *pBiDi)
Get the number of paragraphs.
ubidi_isInverse
UBool ubidi_isInverse(UBiDi *pBiDi)
Is this Bidi object set to perform the inverse Bidi algorithm?
uchar.h
C API: Unicode Properties.
ubidi_getText
const UChar * ubidi_getText(const UBiDi *pBiDi)
Get the pointer to the text.
ubidi_reorderLogical
void ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap)
This is a convenience function that does not use a UBiDi object.
UChar
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:337
UBIDI_LTR
Left-to-right text.
Definition: ubidi.h:431
U_CDECL_END
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:108
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UBIDI_REORDER_INVERSE_LIKE_DIRECT
Visual to Logical algorithm equivalent to the regular Logical to Visual algorithm.
Definition: ubidi.h:718
ubidi_getReorderingOptions
uint32_t ubidi_getReorderingOptions(UBiDi *pBiDi)
What are the reordering options applied to a given Bidi object?
ubidi_countRuns
int32_t ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get the number of runs.
ubidi_getVisualIndex
int32_t ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode)
Get the visual position from a logical text position.
UBiDi
struct UBiDi UBiDi
Definition: ubidi.h:476
ubidi_writeReordered
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_setPara
void ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length, UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels, UErrorCode *pErrorCode)
Perform the Unicode Bidi algorithm.
ubidi_reorderVisual
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
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
UBIDI_REORDER_GROUP_NUMBERS_WITH_R
Logical to Visual algorithm grouping numbers with adjacent R characters (reversible algorithm)...
Definition: ubidi.h:701
LocalUBiDiPointer
"Smart pointer" class, closes a UBiDi via ubidi_close().
UBIDI_NEUTRAL
No strongly directional text.
Definition: ubidi.h:457
ubidi_invertMap
void ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length)
Invert an index map.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UBiDiReorderingMode
UBiDiReorderingMode
UBiDiReorderingMode values indicate which variant of the Bidi algorithm to use.
Definition: ubidi.h:689
U_STABLE
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:134
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:259
UBIDI_RTL
Right-to-left text.
Definition: ubidi.h:443