CharacterCodes.net

Unicode Bidirectional Classes

Every Unicode character is assigned a bidirectional class (often shortened to bidi class), which describes how that character behaves in text that may flow either left-to-right (LTR), right-to-left (RTL), or in a mixture of both. This classification is a core part of the Unicode Bidirectional Algorithm (UBA), a set of rules that determines the correct visual order of characters when scripts like English (LTR) and Arabic or Hebrew (RTL) appear together in the same line. Rather than relying solely on the order in which characters are stored (logical order), the algorithm uses these bidi classes to compute how the text should actually be displayed to the reader.

There are several categories of bidi classes. Strong types include left-to-right letters (such as Latin characters) and right-to-left letters (such as Hebrew and Arabic). Weak types include numbers and certain punctuation, which can adopt directionality based on surrounding text. Neutral types—such as spaces, line breaks, and some symbols—do not inherently carry direction and instead take on the direction of nearby characters. For example, a sequence like “ABC אבג” contains both LTR and RTL text; the bidi algorithm uses the classes of each character to reorder the display so that each script appears in a natural reading order, even though they are stored sequentially.

The algorithm also considers additional factors such as embedding levels and directional overrides, which can be introduced by special formatting characters (e.g., Left-to-Right Embedding, Right-to-Left Override). These allow explicit control over text direction in complex scenarios, such as nested quotations or user interfaces displaying multilingual content. Proper handling of bidi classes is essential in applications like web browsers, text editors, and messaging systems, ensuring that mixed-direction text remains readable and logically consistent. Without this system, combining scripts with different writing directions would lead to confusing or incorrect visual output.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!
If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!