This class provides a bidi transformation engine, i.e. functions for reordering and shaping bidi text.
Bidi stands for support for languages with a bidirectional script.
Usually Unicode Bidi Algorithm used by OS platform (and web browsers) is capable of properly transforming Bidi text and as a result it is adequately displayed on the screen. However, in some situations, Unicode Bidi Algorithm is not invoked or is not properly applied. This may occur in situation in which software responsible for rendering the text is not leveraging Unicode Bidi Algorithm implemented by OS (e.g. dojox.GFX renderers).
Bidi engine provided in this class implements Unicode Bidi Algorithm as specified at http://www.unicode.org/reports/tr9/.
For more information on basic Bidi concepts please read "Bidirectional script support - A primer" available from http://www.ibm.com/developerworks/websphere/library/techarticles/bidi/bidigen.html.
As of February 2011, Bidi engine has following limitations:
See the dojox/string/BidiEngine reference documentation for more information.
Central public API for Bidi engine. Transforms the text according to formatIn, formatOut parameters. If formatIn or formatOut parametrs are not valid throws an exception.
Both formatIn and formatOut parameters are 5 letters long strings. For example - "ILYNN". Each letter is associated with specific attribute of Bidi layout. Possible and default values for each one of the letters are provided below:
First letter:
Second letter:
Third letter:
Fourth letter:
Fifth letter:
The output of this function is original text (passed via first argument) transformed from input Bidi layout (second argument) to output Bidi layout (last argument).
Sample call:
mytext = bidiTransform("HELLO WORLD", "ILYNN", "VLYNN");
In this case, "HELLO WORLD" text is transformed from Logical - LTR to Visual - LTR Bidi layout with
default values for symmetric swapping (Yes), shaping (Not shaped) and numeric shaping (Nominal).
Parameter | Type | Description |
---|---|---|
text | String | |
formatIn | String | Input Bidi layout in which inputText is passed to the function. |
formatOut | String | Output Bidi layout to which inputText should be transformed. |
Original text transformed from input Bidi layout (second argument) to output Bidi layout (last argument). Throws an exception if the bidi layout strings are not valid.
Determine the base direction of a bidi text according to its first strong directional character.
Parameter | Type | Description |
---|---|---|
text | String | The text to check. |
/String/ "ltr" or "rtl" according to the first strong character. If there is no strong character, returns the value of the document dir property.
Return true if text contains RTL directed character.
Iterates over the text string, letter by letter starting from its beginning, searching for RTL directed character. Return true if found else false. Needed for vml transformation.
Parameter | Type | Description |
---|---|---|
text | String | The source string. |
/Boolean/ true - if text has a RTL directed character. false - otherwise.