Bidirectional functions

Bidirectional languages such as Arabic and Hebrew are languages in which the text is presented to the user ordered from right to left, but numbers and Latin alphabetic strings within the text are presented left to right.

In addition, the order in which characters appear within program variables can vary. The text is usually stored in logical order, the order in which the characters are entered in the input field. These differences in ordering and in other associated presentation characteristics require the program to have the ability to convert bidirectional text strings from one format to another.

Use the SETLOGICALORDER, SETVISUALORDER,SETORIENTATIONLTR, SETORIENTATIONRTL, SETTEXTSHAPING, and SETTEXTSHAPINGOFF functions for specific transformation needs when dealing with bidirectional data.

About the order of text

The order of text generally corresponds with way it is stored in memory or on disk. In general, the order of text is displayed, on the screen for example, in visual order so that a person can read it the way it is subjectively meant to be read. That is, left-to-right characters are displayed from left-to-right, and right-to-left characters are displayed with the first character of the text block beginning from the right.

Storage in memory or on disk generally occurs in a logical manner so that the left-to-right characters are stored left-to-right (that is, one after another), and require no processing to display properly. However, when right-to-left characters are stored in a logical manner, they are also stored one after another from left-to-right. These text blocks, when in Logical order, are usually enclosed by markers that identify the start and end positions of the right-to-left text blocks.

Logical to visual reordering

To display these logical sequences on a screen would require that any left-to-right text is simply read and displayed. When right-to-left text is encountered, it must be turned around to the appropriate direction. This is logical-to-visual reordering.

Examples

In the following example, lowercase characters are considered left-to-right (LTR) and uppercase characters are considered right-to-left (RTL).

Text= a b c F E D g h i
Visual order 0x61 0x62 0x63 0x46 0x45 0x44 0x67 0x68 0x69
Logical order 0x61 0x62 0x63 0x44 0x45 0x46 0x67 0x68 0x69