ICU 65.1 65.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"
25
289/*DOCXX_TAG*/
336typedef uint8_t UBiDiLevel;
337
362#define UBIDI_DEFAULT_LTR 0xfe
363
389#define UBIDI_DEFAULT_RTL 0xff
390
398#define UBIDI_MAX_EXPLICIT_LEVEL 125
399
404#define UBIDI_LEVEL_OVERRIDE 0x80
405
419#define UBIDI_MAP_NOWHERE (-1)
420
465
468
479struct UBiDi;
480
482typedef struct UBiDi UBiDi;
483
499U_STABLE UBiDi * U_EXPORT2
501
536U_STABLE UBiDi * U_EXPORT2
537ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
538
559U_STABLE void U_EXPORT2
561
562#if U_SHOW_CPLUSPLUS_API
563
564U_NAMESPACE_BEGIN
565
576
577U_NAMESPACE_END
578
579#endif
580
629U_STABLE void U_EXPORT2
630ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
631
648U_STABLE UBool U_EXPORT2
650
671U_STABLE void U_EXPORT2
672ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
673
685U_STABLE UBool U_EXPORT2
687
737
889U_STABLE void U_EXPORT2
891
902
1031
1045U_STABLE void U_EXPORT2
1046ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
1047
1056U_STABLE uint32_t U_EXPORT2
1058
1143U_STABLE void U_EXPORT2
1145 const UChar *prologue, int32_t proLength,
1146 const UChar *epilogue, int32_t epiLength,
1147 UErrorCode *pErrorCode);
1148
1231U_STABLE void U_EXPORT2
1232ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
1233 UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
1234 UErrorCode *pErrorCode);
1235
1282U_STABLE void U_EXPORT2
1283ubidi_setLine(const UBiDi *pParaBiDi,
1284 int32_t start, int32_t limit,
1285 UBiDi *pLineBiDi,
1286 UErrorCode *pErrorCode);
1287
1303U_STABLE UBiDiDirection U_EXPORT2
1305
1333U_STABLE UBiDiDirection U_EXPORT2
1334ubidi_getBaseDirection(const UChar *text, int32_t length );
1335
1347U_STABLE const UChar * U_EXPORT2
1348ubidi_getText(const UBiDi *pBiDi);
1349
1358U_STABLE int32_t U_EXPORT2
1360
1376U_STABLE UBiDiLevel U_EXPORT2
1378
1387U_STABLE int32_t U_EXPORT2
1389
1424U_STABLE int32_t U_EXPORT2
1425ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
1426 int32_t *pParaLimit, UBiDiLevel *pParaLevel,
1427 UErrorCode *pErrorCode);
1428
1456U_STABLE void U_EXPORT2
1457ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
1458 int32_t *pParaStart, int32_t *pParaLimit,
1459 UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);
1460
1476U_STABLE UBiDiLevel U_EXPORT2
1477ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
1478
1497U_STABLE const UBiDiLevel * U_EXPORT2
1498ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode);
1499
1524U_STABLE void U_EXPORT2
1525ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
1526 int32_t *pLogicalLimit, UBiDiLevel *pLevel);
1527
1543U_STABLE int32_t U_EXPORT2
1544ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
1545
1602U_STABLE UBiDiDirection U_EXPORT2
1603ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
1604 int32_t *pLogicalStart, int32_t *pLength);
1605
1643U_STABLE int32_t U_EXPORT2
1644ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);
1645
1678U_STABLE int32_t U_EXPORT2
1679ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);
1680
1721U_STABLE void U_EXPORT2
1722ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1723
1757U_STABLE void U_EXPORT2
1758ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1759
1780U_STABLE void U_EXPORT2
1781ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1782
1803U_STABLE void U_EXPORT2
1804ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1805
1838U_STABLE void U_EXPORT2
1839ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
1840
1850#define UBIDI_KEEP_BASE_COMBINING 1
1851
1860#define UBIDI_DO_MIRRORING 2
1861
1874#define UBIDI_INSERT_LRM_FOR_NUMERIC 4
1875
1887#define UBIDI_REMOVE_BIDI_CONTROLS 8
1888
1903#define UBIDI_OUTPUT_REVERSE 16
1904
1943U_STABLE int32_t U_EXPORT2
1945
1973U_STABLE int32_t U_EXPORT2
1975
1977
1978#ifndef U_HIDE_DEPRECATED_API
1988#define U_BIDI_CLASS_DEFAULT U_CHAR_DIRECTION_COUNT
1989#endif // U_HIDE_DEPRECATED_API
1990
2012UBiDiClassCallback(const void *context, UChar32 c);
2013
2015
2031U_STABLE UCharDirection U_EXPORT2
2033
2061U_STABLE void U_EXPORT2
2063 const void *newContext, UBiDiClassCallback **oldFn,
2064 const void **oldContext, UErrorCode *pErrorCode);
2065
2078U_STABLE void U_EXPORT2
2079ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);
2080
2146U_STABLE int32_t U_EXPORT2
2148 UChar *dest, int32_t destSize,
2149 uint16_t options,
2150 UErrorCode *pErrorCode);
2151
2198U_STABLE int32_t U_EXPORT2
2199ubidi_writeReverse(const UChar *src, int32_t srcLength,
2200 UChar *dest, int32_t destSize,
2201 uint16_t options,
2202 UErrorCode *pErrorCode);
2203
2204/*#define BIDI_SAMPLE_CODE*/
2207#endif
"Smart pointer" class, closes a UBiDi via ubidi_close().
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition platform.h:870
void ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap)
This is a convenience function that does not use a UBiDi object.
void ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context)
Get the current callback function used for Bidi class determination.
int32_t ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode)
Get the visual position from a logical text position.
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.
int32_t ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get the number of runs.
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().
void ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions)
Specify which of the reordering options should be applied during Bidi transformations.
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_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.
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.
int32_t ubidi_getResultLength(const UBiDi *pBiDi)
Get the length of the reordered text resulting from the last call to ubidi_setPara().
void ubidi_close(UBiDi *pBiDi)
ubidi_close() must be called to free the memory associated with a UBiDi object.
UBiDiReorderingOption
UBiDiReorderingOption values indicate which options are specified to affect the Bidi algorithm.
Definition ubidi.h:910
@ UBIDI_OPTION_INSERT_MARKS
option bit for ubidi_setReorderingOptions: insert Bidi marks (LRM or RLM) when needed to ensure corre...
Definition ubidi.h:963
@ UBIDI_OPTION_STREAMING
option bit for ubidi_setReorderingOptions: process the output as part of a stream to be continued
Definition ubidi.h:1029
@ UBIDI_OPTION_DEFAULT
option value for ubidi_setReorderingOptions: disable all the options which can be set with this funct...
Definition ubidi.h:917
@ UBIDI_OPTION_REMOVE_CONTROLS
option bit for ubidi_setReorderingOptions: remove Bidi control characters
Definition ubidi.h:981
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...
uint32_t ubidi_getReorderingOptions(UBiDi *pBiDi)
What are the reordering options applied to a given Bidi object?
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.
UBool ubidi_isOrderParagraphsLTR(UBiDi *pBiDi)
Is this Bidi object set to allocate level 0 to block separators so that successive paragraphs progres...
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.
UBiDiLevel ubidi_getParaLevel(const UBiDi *pBiDi)
Get the paragraph level of the text.
UBiDiDirection
UBiDiDirection values indicate the text direction.
Definition ubidi.h:425
@ UBIDI_LTR
Left-to-right text.
Definition ubidi.h:437
@ UBIDI_NEUTRAL
No strongly directional text.
Definition ubidi.h:463
@ UBIDI_MIXED
Mixed-directional text.
Definition ubidi.h:456
@ UBIDI_RTL
Right-to-left text.
Definition ubidi.h:449
UCharDirection UBiDiClassCallback(const void *context, UChar32 c)
Callback type declaration for overriding default Bidi class values with custom ones.
Definition ubidi.h:2012
UBool ubidi_isInverse(UBiDi *pBiDi)
Is this Bidi object set to perform the inverse Bidi algorithm?
UCharDirection ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c)
Retrieve the Bidi class for a given code point.
void ubidi_setInverse(UBiDi *pBiDi, UBool isInverse)
Modify the operation of the Bidi algorithm such that it approximates an "inverse Bidi" algorithm.
UBiDiReorderingMode
UBiDiReorderingMode values indicate which variant of the Bidi algorithm to use.
Definition ubidi.h:695
@ UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL
Inverse Bidi (Visual to Logical) algorithm for the UBIDI_REORDER_NUMBERS_SPECIAL Bidi algorithm.
Definition ubidi.h:728
@ UBIDI_REORDER_GROUP_NUMBERS_WITH_R
Logical to Visual algorithm grouping numbers with adjacent R characters (reversible algorithm).
Definition ubidi.h:707
@ 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:715
@ UBIDI_REORDER_NUMBERS_SPECIAL
Logical to Visual algorithm which handles numbers in a way which mimics the behavior of Windows XP.
Definition ubidi.h:703
@ 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:720
@ UBIDI_REORDER_INVERSE_LIKE_DIRECT
Visual to Logical algorithm equivalent to the regular Logical to Visual algorithm.
Definition ubidi.h:724
@ UBIDI_REORDER_DEFAULT
Regular Logical to Visual Bidi algorithm according to Unicode.
Definition ubidi.h:699
@ UBIDI_REORDER_COUNT
Number of values for reordering mode.
Definition ubidi.h:734
int32_t ubidi_countParagraphs(UBiDi *pBiDi)
Get the number of paragraphs.
int32_t ubidi_getLength(const UBiDi *pBiDi)
Get the length of the text.
int32_t ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode)
Get the logical text position from a visual position.
UBiDiReorderingMode ubidi_getReorderingMode(UBiDi *pBiDi)
What is the requested reordering mode for a given Bidi object?
UBiDi * ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode)
Allocate a UBiDi structure with preallocated memory for internal structures.
const UBiDiLevel * ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get an array of levels for each character.
void ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition, int32_t *pLogicalLimit, UBiDiLevel *pLevel)
Get a logical run.
uint8_t UBiDiLevel
UBiDiLevel is the type of the level values in this Bidi implementation.
Definition ubidi.h:336
void ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR)
Specify whether block separators must be allocated level zero, so that successive paragraphs will pro...
void ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length, UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels, UErrorCode *pErrorCode)
Perform the Unicode Bidi algorithm.
int32_t ubidi_getProcessedLength(const UBiDi *pBiDi)
Get the length of the source text processed by the last call to ubidi_setPara().
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 * ubidi_open(void)
Allocate a UBiDi structure.
UBiDiLevel ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex)
Get the level for one character.
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.
UBiDiDirection ubidi_getBaseDirection(const UChar *text, int32_t length)
Gets the base direction of the text provided according to the Unicode Bidirectional Algorithm.
struct UBiDi UBiDi
Definition ubidi.h:482
UBiDiDirection ubidi_getDirection(const UBiDi *pBiDi)
Get the directionality of the text.
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.
void ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length)
Invert an index map.
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...
C API: Unicode Properties.
UCharDirection
This specifies the language directional property of a character set.
Definition uchar.h:921
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition umachine.h:425
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition umachine.h:85
int8_t UBool
The ICU boolean type.
Definition umachine.h:261
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:378
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition umachine.h:84
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition umachine.h:111
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:415