C API: Bidi Transformations.More...
#include "unicode/utypes.h"#include "unicode/ubidi.h"#include "unicode/uchar.h"#include "unicode/localpointer.h"Go to the source code of this file.
Namespaces | |
| icu | |
| Filecoll.h. | |
Typedefs | |
| typedef structUBiDiTransform | UBiDiTransform |
Forward declaration of theUBiDiTransform structure that stores information used by the layout transformation engine.More... | |
Enumerations | |
| enum | UBiDiOrder {UBIDI_LOGICAL = 0,UBIDI_VISUAL } |
UBiDiOrder indicates the order of text.More... | |
| enum | UBiDiMirroring {UBIDI_MIRRORING_OFF = 0,UBIDI_MIRRORING_ON } |
UBiDiMirroring indicates whether or not characters with the "mirrored" property in RTL runs should be replaced with their mirror-image counterparts.More... | |
Functions | |
| U_CAPI uint32_t | ubiditransform_transform (UBiDiTransform *pBiDiTransform, constUChar *src, int32_t srcLength,UChar *dest, int32_t destSize,UBiDiLevel inParaLevel,UBiDiOrder inOrder,UBiDiLevel outParaLevel,UBiDiOrder outOrder,UBiDiMirroring doMirroring, uint32_t shapingOptions,UErrorCode *pErrorCode) |
| Performs transformation of text from the bidi layout defined by the input ordering scheme to the bidi layout defined by the output ordering scheme, and applies character mirroring and Arabic shaping operations.More... | |
| U_CAPIUBiDiTransform * | ubiditransform_open (UErrorCode *pErrorCode) |
Allocates aUBiDiTransform object.More... | |
| U_CAPI void | ubiditransform_close (UBiDiTransform *pBidiTransform) |
Deallocates the givenUBiDiTransform object.More... | |
C API: Bidi Transformations.
Definition in fileubiditransform.h.
| typedef structUBiDiTransformUBiDiTransform |
Forward declaration of theUBiDiTransform structure that stores information used by the layout transformation engine.
Definition at line1 of fileubiditransform.h.
| enumUBiDiMirroring |
UBiDiMirroring indicates whether or not characters with the "mirrored" property in RTL runs should be replaced with their mirror-image counterparts.
| Enumerator | |
|---|---|
| UBIDI_MIRRORING_OFF | 0: Constant indicating that character mirroring should not be performed. This is the default.
|
| UBIDI_MIRRORING_ON | 1: Constant indicating that character mirroring should be performed. This corresponds to calling
|
Definition at line94 of fileubiditransform.h.
| enumUBiDiOrder |
UBiDiOrder indicates the order of text.
This bidi transformation engine supports all possible combinations (4 in total) of input and output text order:
UBiDi when the reordering mode is set toUBIDI_REORDER_DEFAULT. Visual RTL mode is not supported byUBiDi and is accomplished through reversing a visual LTR string,UBiDi with the reordering mode set toUBIDI_REORDER_INVERSE_LIKE_DIRECT. Visual RTL mode is not not supported byUBiDi and is accomplished through reversing a visual LTR string,UBiDi implementation with the reordering mode set toUBIDI_REORDER_RUNS_ONLY; and if the input and output base directions are identical, the transformation engine will only handle character mirroring and Arabic shaping operations without reordering,UBiDi engine; it implies character mirroring, Arabic shaping, and - if the input/output base directions mismatch - string reverse operations.| Enumerator | |
|---|---|
| UBIDI_LOGICAL | 0: Constant indicating a logical order. This is the default for input text.
|
| UBIDI_VISUAL | 1: Constant indicating a visual order. This is a default for output text.
|
Definition at line71 of fileubiditransform.h.
| U_CAPI void ubiditransform_close | ( | UBiDiTransform * | pBidiTransform | ) |
Deallocates the givenUBiDiTransform object.
| U_CAPIUBiDiTransform* ubiditransform_open | ( | UErrorCode * | pErrorCode | ) |
Allocates aUBiDiTransform object.
This object can be reused, e.g. with different ordering schemes, mirroring or shaping options.
Note:The object can only be reused in the same thread. All other threads should allocate a newUBiDiTransform object before using it.
Example of usage:
UErrorCode errorCode =U_ZERO_ERROR;// Open a new UBiDiTransform.UBiDiTransform* transform =ubiditransform_open(&errorCode);// Run a transformation.ubiditransform_transform(transform,text1, -1, text2, -1,&errorCode);// Do something with the output text and invoke another transformation using// that text as input.ubiditransform_transform(transform,text2, -1, text3, -1,0, &errorCode);*U_CAPI uint32_t ubiditransform_transform(UBiDiTransform *pBiDiTransform, const UChar *src, int32_t srcLength, UChar *dest, int32_t destSize, UBiDiLevel inParaLevel, UBiDiOrder inOrder, UBiDiLevel outParaLevel, UBiDiOrder outOrder, UBiDiMirroring doMirroring, uint32_t shapingOptions, UErrorCode *pErrorCode)Performs transformation of text from the bidi layout defined by the input ordering scheme to the bidi...struct UBiDiTransform UBiDiTransformForward declaration of the UBiDiTransform structure that stores information used by the layout transf...Definition:ubiditransform.h:115U_CAPI UBiDiTransform * ubiditransform_open(UErrorCode *pErrorCode)Allocates a UBiDiTransform object.@ UBIDI_MIRRORING_ON1: Constant indicating that character mirroring should be performed.Definition:ubiditransform.h:107#define U_SHAPE_DIGITS_EN2ANDigit shaping option: Replace European digits (U+0030...) by Arabic-Indic digits.Definition:ushape.h:251
TheUBiDiTransform object must be deallocated by callingubiditransform_close().
UBiDiTransform object.| U_CAPI uint32_t ubiditransform_transform | ( | UBiDiTransform * | pBiDiTransform, |
| constUChar * | src, | ||
| int32_t | srcLength, | ||
| UChar * | dest, | ||
| int32_t | destSize, | ||
| UBiDiLevel | inParaLevel, | ||
| UBiDiOrder | inOrder, | ||
| UBiDiLevel | outParaLevel, | ||
| UBiDiOrder | outOrder, | ||
| UBiDiMirroring | doMirroring, | ||
| uint32_t | shapingOptions, | ||
| UErrorCode * | pErrorCode | ||
| ) |
Performs transformation of text from the bidi layout defined by the input ordering scheme to the bidi layout defined by the output ordering scheme, and applies character mirroring and Arabic shaping operations.
In terms ofUBiDi, such a transformation implies:
ubidi_setReorderingMode as needed (when the reordering mode is other than normal),ubidi_setInverse as needed (when text should be transformed from a visual to a logical form),ubidi_setPara,ubidi_writeReordered,u_shapeArabic.An "ordering scheme" encompasses the base direction and the order of text, and these characteristics must be defined by the caller for both input and output explicitly .
There are 36 possible combinations of <input, output> ordering schemes, which are partially supported byUBiDi already. Examples of the currently supported combinations:
ubidi_setPara withparaLevel == UBIDI_LTR,ubidi_setPara withparaLevel == UBIDI_RTL,ubidi_setPara withparaLevel == UBIDI_DEFAULT_LTR,ubidi_setPara withparaLevel == UBIDI_DEFAULT_RTL,ubidi_setInverse(UBiDi*, true) and thenubidi_setPara withparaLevel == UBIDI_LTR,ubidi_setInverse(UBiDi*, true) and thenubidi_setPara withparaLevel == UBIDI_RTL.All combinations that involve the Visual RTL scheme are unsupported byUBiDi, for instance:
Example of usage of the transformation engine:
UErrorCode errorCode =U_ZERO_ERROR;// Run a transformation.ubiditransform_transform(pBidiTransform,text1, -1, text2, -1,&errorCode);// Do something with text2.text2[4] ='2';// Run a reverse transformation.ubiditransform_transform(pBidiTransform,text2, -1, text1, -1,&errorCode);*@ UBIDI_MIRRORING_OFF0: Constant indicating that character mirroring should not be performed.Definition:ubiditransform.h:100#define U_SHAPE_DIGITS_AN2ENDigit shaping option: Replace Arabic-Indic digits by European digits (U+0030...).Definition:ushape.h:258#define U_SHAPE_DIGIT_TYPE_AN_EXTENDEDDigit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9).Definition:ushape.h:296
| pBiDiTransform | A pointer to aUBiDiTransform object allocated withubiditransform_open() orNULL. |
This object serves for one-time setup to amortize initialization overheads. Use of this object is not thread-safe. All other threads should allocate a newUBiDiTransform object by callingubiditransform_open() before using it. Alternatively, a caller can set this parameter toNULL, in which case the object will be allocated by the engine on the fly.
| src | A pointer to the text that the Bidi layout transformations will be performed on. |
Note: the text must be (at least)srcLength long.
| srcLength | The length of the text, in number of UChars. Iflength == -1 then the text must be zero-terminated. |
| dest | A pointer to where the processed text is to be copied. |
| destSize | The size of thedest buffer, in number of UChars. If theU_SHAPE_LETTERS_UNSHAPE option is set, then the destination length could be as large assrcLength * 2. Otherwise, the destination length will not exceedsrcLength. If the caller reserves the last position for zero-termination, it should be excluded fromdestSize. |
destSize == -1 is allowed and makes sense whendest was holds some meaningful value, e.g. that ofsrc. In this casedest must be zero-terminated.
| inParaLevel | A base embedding level of the input as defined inubidi_setPara documentation for theparaLevel parameter. |
| inOrder | An order of the input, which can be one of theUBiDiOrder values. |
| outParaLevel | A base embedding level of the output as defined inubidi_setPara documentation for theparaLevel parameter. |
| outOrder | An order of the output, which can be one of theUBiDiOrder values. |
| doMirroring | Indicates whether or not to perform character mirroring, and can accept one of theUBiDiMirroring values. |
| shapingOptions | Arabic digit and letter shaping options defined in theushape.h documentation. |
Note: Direction indicator options are computed by the transformation engine based on the effective ordering schemes, so user-defined direction indicators will be ignored.
| pErrorCode | A pointer to an error code value. |
dest. If the transformation fails, the return value will be 0 (and the error code will be written topErrorCode).