ICU4C 79
Loading...
Searching...
No Matches
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/unistr.h"
23#include "unicode/utypes.h"
24#include "unicode/uchar.h"
25
26#if U_SHOW_CPLUSPLUS_API
28#endif // U_SHOW_CPLUSPLUS_API
29
293
294/*DOCXX_TAG*/
296
341typedef uint8_t UBiDiLevel;
342
367#define UBIDI_DEFAULT_LTR 0xfe
368
394#define UBIDI_DEFAULT_RTL 0xff
395
403#define UBIDI_MAX_EXPLICIT_LEVEL 125
404
409#define UBIDI_LEVEL_OVERRIDE 0x80
410
424#define UBIDI_MAP_NOWHERE (-1)
425
470
473
484struct UBiDi;
485
487typedef struct UBiDi UBiDi;
488
504U_CAPI UBiDi * U_EXPORT2
506
541U_CAPI UBiDi * U_EXPORT2
542ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode);
543
564U_CAPI void U_EXPORT2
566
567#if U_SHOW_CPLUSPLUS_API
568
569U_NAMESPACE_BEGIN
570
581
582U_NAMESPACE_END
583
584#endif
585
634U_CAPI void U_EXPORT2
635ubidi_setInverse(UBiDi *pBiDi, UBool isInverse);
636
652
653U_CAPI UBool U_EXPORT2
655
676U_CAPI void U_EXPORT2
677ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR);
678
690U_CAPI UBool U_EXPORT2
692
742
894U_CAPI void U_EXPORT2
896
907
1036
1050U_CAPI void U_EXPORT2
1051ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions);
1052
1061U_CAPI uint32_t U_EXPORT2
1063
1148U_CAPI void U_EXPORT2
1150 const UChar *prologue, int32_t proLength,
1151 const UChar *epilogue, int32_t epiLength,
1152 UErrorCode *pErrorCode);
1153
1236U_CAPI void U_EXPORT2
1237ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
1238 UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels,
1239 UErrorCode *pErrorCode);
1240
1287U_CAPI void U_EXPORT2
1288ubidi_setLine(const UBiDi *pParaBiDi,
1289 int32_t start, int32_t limit,
1290 UBiDi *pLineBiDi,
1291 UErrorCode *pErrorCode);
1292
1308U_CAPI UBiDiDirection U_EXPORT2
1310
1338U_CAPI UBiDiDirection U_EXPORT2
1339ubidi_getBaseDirection(const UChar *text, int32_t length );
1340
1352U_CAPI const UChar* U_EXPORT2
1353ubidi_getText(const UBiDi* pBiDi);
1354
1363U_CAPI int32_t U_EXPORT2
1365
1381U_CAPI UBiDiLevel U_EXPORT2
1383
1392U_CAPI int32_t U_EXPORT2
1394
1429U_CAPI int32_t U_EXPORT2
1430ubidi_getParagraph(const UBiDi *pBiDi, int32_t charIndex, int32_t *pParaStart,
1431 int32_t *pParaLimit, UBiDiLevel *pParaLevel,
1432 UErrorCode *pErrorCode);
1433
1461U_CAPI void U_EXPORT2
1462ubidi_getParagraphByIndex(const UBiDi *pBiDi, int32_t paraIndex,
1463 int32_t *pParaStart, int32_t *pParaLimit,
1464 UBiDiLevel *pParaLevel, UErrorCode *pErrorCode);
1465
1481U_CAPI UBiDiLevel U_EXPORT2
1482ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex);
1483
1502U_CAPI const UBiDiLevel* U_EXPORT2
1503ubidi_getLevels(UBiDi* pBiDi, UErrorCode* pErrorCode);
1504
1529U_CAPI void U_EXPORT2
1530ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition,
1531 int32_t *pLogicalLimit, UBiDiLevel *pLevel);
1532
1548U_CAPI int32_t U_EXPORT2
1549ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
1550
1607U_CAPI UBiDiDirection U_EXPORT2
1608ubidi_getVisualRun(UBiDi *pBiDi, int32_t runIndex,
1609 int32_t *pLogicalStart, int32_t *pLength);
1610
1648U_CAPI int32_t U_EXPORT2
1649ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode);
1650
1683U_CAPI int32_t U_EXPORT2
1684ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode);
1685
1726U_CAPI void U_EXPORT2
1727ubidi_getLogicalMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1728
1762U_CAPI void U_EXPORT2
1763ubidi_getVisualMap(UBiDi *pBiDi, int32_t *indexMap, UErrorCode *pErrorCode);
1764
1785U_CAPI void U_EXPORT2
1786ubidi_reorderLogical(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1787
1808U_CAPI void U_EXPORT2
1809ubidi_reorderVisual(const UBiDiLevel *levels, int32_t length, int32_t *indexMap);
1810
1843U_CAPI void U_EXPORT2
1844ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length);
1845
1847
1855#define UBIDI_KEEP_BASE_COMBINING 1
1856
1865#define UBIDI_DO_MIRRORING 2
1866
1879#define UBIDI_INSERT_LRM_FOR_NUMERIC 4
1880
1892#define UBIDI_REMOVE_BIDI_CONTROLS 8
1893
1908#define UBIDI_OUTPUT_REVERSE 16
1909
1948U_CAPI int32_t U_EXPORT2
1950
1978U_CAPI int32_t U_EXPORT2
1980
1982
1983#ifndef U_HIDE_DEPRECATED_API
1993#define U_BIDI_CLASS_DEFAULT U_CHAR_DIRECTION_COUNT
1994#endif // U_HIDE_DEPRECATED_API
1995
2017UBiDiClassCallback(const void *context, UChar32 c);
2018
2020
2036U_CAPI UCharDirection U_EXPORT2
2038
2066U_CAPI void U_EXPORT2
2068 const void *newContext, UBiDiClassCallback **oldFn,
2069 const void **oldContext, UErrorCode *pErrorCode);
2070
2083U_CAPI void U_EXPORT2
2084ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context);
2085
2151U_CAPI int32_t U_EXPORT2
2153 UChar *dest, int32_t destSize,
2154 uint16_t options,
2155 UErrorCode *pErrorCode);
2156
2203U_CAPI int32_t U_EXPORT2
2204ubidi_writeReverse(const UChar *src, int32_t srcLength,
2205 UChar *dest, int32_t destSize,
2206 uint16_t options,
2207 UErrorCode *pErrorCode);
2208
2209/*#define BIDI_SAMPLE_CODE*/
2211
2212/* Utilities for MessageFormat ------------------------------------------------*/
2213
2214#if U_SHOW_CPLUSPLUS_API
2215
2216U_NAMESPACE_BEGIN
2217
2258
2290
2315 U_MF_BIDI_DEFAULT = U_MF_BIDI_AUTO
2316} UMFBidiIsolationStrategy;
2317
2340 U_MF_BIDI_STYLE_DEFAULT = U_MF_BIDI_STYLE_CONTROL
2341} UMFBidiIsolationStyle;
2342
2354U_CAPI UMFBidiOption U_EXPORT2
2356
2375U_CAPI UnicodeString* U_EXPORT2
2377 UMFDirectionality msgdir,
2378 UMFBidiIsolationStyle bidiIsolationStyle,
2379 UMFBidiOption uDirOption,
2381 UnicodeString& fmt);
2382
2383U_NAMESPACE_END
2384
2385#endif
2386
2387#endif
"Smart pointer" class, closes a UBiDi via ubidi_close().
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
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.
UMFBidiIsolationStrategy
Used in conjunction with the MessageFormatter::Builder::setBidiIsolationStrategy() method.
Definition ubidi.h:2298
@ U_MF_BIDI_AUTO
Perform bidi isolation using the "default" strategy described in the MF2 specification (default).
Definition ubidi.h:2314
@ U_MF_BIDI_OFF
Do not perform bidi isolation.
Definition ubidi.h:2305
U_CAPI UMFBidiOption ubidi_getMFOption(const UnicodeString &s)
Convert a string to a UMFBidiOption, representing text directionality.
UMFBidiIsolationStyle
Used in conjunction with the MessageFormatter::Builder::setBidiIsolationStyle() method.
Definition ubidi.h:2325
@ U_MF_BIDI_STYLE_CONTROL
Insert bidi control characters for isolation.
Definition ubidi.h:2332
@ U_MF_BIDI_STYLE_HTML
Insert HTML markup tags for isolation.
Definition ubidi.h:2339
UMFBidiOption
Used to denote the directionality of the input to a function.
Definition ubidi.h:2226
@ U_MF_BIDI_OPTION_INHERIT
Directionality inherited from the message without requiring isolation of the expression value.
Definition ubidi.h:2256
@ U_MF_BIDI_OPTION_AUTO
Directionality determined from expression contents.
Definition ubidi.h:2247
@ U_MF_BIDI_OPTION_LTR
Left-to-right directionality.
Definition ubidi.h:2233
@ U_MF_BIDI_OPTION_RTL
Right-to-left directionality.
Definition ubidi.h:2240
U_CAPI UnicodeString * ubidi_isolate(UMFBidiIsolationStrategy bidiIsolationStrategy, UMFDirectionality msgdir, UMFBidiIsolationStyle bidiIsolationStyle, UMFBidiOption uDirOption, UMFDirectionality dir, UnicodeString &fmt)
Isolate a string according to the "Default Bidi Strategy" from the MessageFormat specification https:...
UMFDirectionality
Used to represent the directionality of a message, where the AUTO setting has been resolved based on ...
Definition ubidi.h:2266
@ U_MF_DIRECTIONALITY_RTL
Denotes a right-to-left message.
Definition ubidi.h:2280
@ U_MF_DIRECTIONALITY_LTR
Denotes a left-to-right message.
Definition ubidi.h:2273
@ U_MF_DIRECTIONALITY_UNKNOWN
Denotes a message with unknown directionality.
Definition ubidi.h:2287
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
Definition platform.h:880
U_CAPI void ubidi_getLogicalRun(const UBiDi *pBiDi, int32_t logicalPosition, int32_t *pLogicalLimit, UBiDiLevel *pLevel)
Get a logical run.
U_CAPI int32_t ubidi_countParagraphs(UBiDi *pBiDi)
Get the number of paragraphs.
U_CAPI int32_t ubidi_countRuns(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get the number of runs.
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.
U_CAPI int32_t ubidi_getLength(const UBiDi *pBiDi)
Get the length of the text.
U_CAPI const UChar * ubidi_getText(const UBiDi *pBiDi)
Get the pointer to the text.
U_CAPI UCharDirection ubidi_getCustomizedClass(UBiDi *pBiDi, UChar32 c)
Retrieve the Bidi class for a given code point.
UBiDiReorderingOption
UBiDiReorderingOption values indicate which options are specified to affect the Bidi algorithm.
Definition ubidi.h:915
@ UBIDI_OPTION_INSERT_MARKS
option bit for ubidi_setReorderingOptions: insert Bidi marks (LRM or RLM) when needed to ensure corre...
Definition ubidi.h:968
@ UBIDI_OPTION_STREAMING
option bit for ubidi_setReorderingOptions: process the output as part of a stream to be continued
Definition ubidi.h:1034
@ UBIDI_OPTION_DEFAULT
option value for ubidi_setReorderingOptions: disable all the options which can be set with this funct...
Definition ubidi.h:922
@ UBIDI_OPTION_REMOVE_CONTROLS
option bit for ubidi_setReorderingOptions: remove Bidi control characters
Definition ubidi.h:986
U_CAPI int32_t ubidi_getProcessedLength(const UBiDi *pBiDi)
Get the length of the source text processed by the last call to ubidi_setPara().
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.
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,...
U_CAPI void ubidi_close(UBiDi *pBiDi)
ubidi_close() must be called to free the memory associated with a UBiDi object.
UBiDiDirection
UBiDiDirection values indicate the text direction.
Definition ubidi.h:430
@ UBIDI_LTR
Left-to-right text.
Definition ubidi.h:442
@ UBIDI_NEUTRAL
No strongly directional text.
Definition ubidi.h:468
@ UBIDI_MIXED
Mixed-directional text.
Definition ubidi.h:461
@ UBIDI_RTL
Right-to-left text.
Definition ubidi.h:454
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...
U_CAPI void ubidi_setReorderingOptions(UBiDi *pBiDi, uint32_t reorderingOptions)
Specify which of the reordering options should be applied during Bidi transformations.
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...
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.
UCharDirection UBiDiClassCallback(const void *context, UChar32 c)
Callback type declaration for overriding default Bidi class values with custom ones.
Definition ubidi.h:2017
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.
UBiDiReorderingMode
UBiDiReorderingMode values indicate which variant of the Bidi algorithm to use.
Definition ubidi.h:700
@ UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL
Inverse Bidi (Visual to Logical) algorithm for the UBIDI_REORDER_NUMBERS_SPECIAL Bidi algorithm.
Definition ubidi.h:733
@ UBIDI_REORDER_GROUP_NUMBERS_WITH_R
Logical to Visual algorithm grouping numbers with adjacent R characters (reversible algorithm).
Definition ubidi.h:712
@ 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:720
@ UBIDI_REORDER_NUMBERS_SPECIAL
Logical to Visual algorithm which handles numbers in a way which mimics the behavior of Windows XP.
Definition ubidi.h:708
@ 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:725
@ UBIDI_REORDER_INVERSE_LIKE_DIRECT
Visual to Logical algorithm equivalent to the regular Logical to Visual algorithm.
Definition ubidi.h:729
@ UBIDI_REORDER_DEFAULT
Regular Logical to Visual Bidi algorithm according to Unicode.
Definition ubidi.h:704
@ UBIDI_REORDER_COUNT
Number of values for reordering mode.
Definition ubidi.h:739
U_CAPI UBiDi * ubidi_openSized(int32_t maxLength, int32_t maxRunCount, UErrorCode *pErrorCode)
Allocate a UBiDi structure with preallocated memory for internal structures.
U_CAPI UBool ubidi_isInverse(UBiDi *pBiDi)
Is this Bidi object set to perform the inverse Bidi algorithm?
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.
U_CAPI void ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length, UBiDiLevel paraLevel, UBiDiLevel *embeddingLevels, UErrorCode *pErrorCode)
Perform the Unicode Bidi algorithm.
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.
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.
U_CAPI uint32_t ubidi_getReorderingOptions(UBiDi *pBiDi)
What are the reordering options applied to a given Bidi object?
U_CAPI const UBiDiLevel * ubidi_getLevels(UBiDi *pBiDi, UErrorCode *pErrorCode)
Get an array of levels for each character.
U_CAPI UBiDi * ubidi_open(void)
Allocate a UBiDi structure.
U_CAPI UBiDiDirection ubidi_getDirection(const UBiDi *pBiDi)
Get the directionality of the text.
U_CAPI void ubidi_getClassCallback(UBiDi *pBiDi, UBiDiClassCallback **fn, const void **context)
Get the current callback function used for Bidi class determination.
uint8_t UBiDiLevel
UBiDiLevel is the type of the level values in this Bidi implementation.
Definition ubidi.h:341
U_CAPI void ubidi_orderParagraphsLTR(UBiDi *pBiDi, UBool orderParagraphsLTR)
Specify whether block separators must be allocated level zero, so that successive paragraphs will pro...
U_CAPI int32_t ubidi_getResultLength(const UBiDi *pBiDi)
Get the length of the reordered text resulting from the last call to ubidi_setPara().
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().
U_CAPI int32_t ubidi_getVisualIndex(UBiDi *pBiDi, int32_t logicalIndex, UErrorCode *pErrorCode)
Get the visual position from a logical text position.
U_CAPI UBiDiLevel ubidi_getParaLevel(const UBiDi *pBiDi)
Get the paragraph level of the text.
U_CAPI UBiDiLevel ubidi_getLevelAt(const UBiDi *pBiDi, int32_t charIndex)
Get the level for one character.
U_CAPI UBool ubidi_isOrderParagraphsLTR(UBiDi *pBiDi)
Is this Bidi object set to allocate level 0 to block separators so that successive paragraphs progres...
U_CAPI int32_t ubidi_getLogicalIndex(UBiDi *pBiDi, int32_t visualIndex, UErrorCode *pErrorCode)
Get the logical text position from a visual position.
U_CAPI void ubidi_invertMap(const int32_t *srcMap, int32_t *destMap, int32_t length)
Invert an index map.
U_CAPI void ubidi_setInverse(UBiDi *pBiDi, UBool isInverse)
Modify the operation of the Bidi algorithm such that it approximates an "inverse Bidi" algorithm.
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_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.
struct UBiDi UBiDi
Definition ubidi.h:487
U_CAPI UBiDiReorderingMode ubidi_getReorderingMode(UBiDi *pBiDi)
What is the requested reordering mode for a given Bidi object?
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...
C API: Unicode Properties.
UCharDirection
This specifies the language directional property of a character set.
Definition uchar.h:1023
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:400
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition umachine.h:449
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition umachine.h:86
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition umachine.h:85
C++ API: Unicode String.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509