Unicode bidirectional class 2026-11-05
A Unicode bidirectional class is a character property, formally named
Bidi_Class, used as input to the Unicode Bidirectional Algorithm. It classifies directional behavior; the algorithm combines the properties with context to compute bidirectional embedding levels. A class is not itself a final screen position.[ref]Unicode Bidirectional Algorithm (Revision 51) by the Unicode Consortium. definitionBD1 and section3.2, Table4: bidirectional character types
For a compact example, Latin A (
U+0041) has classL, Hebrew alef (U+05D0) has classR, digit1 (U+0031) has classEN, and ordinary space (U+0020) has classWS. These labels distinguish strong directions, a numeric class and whitespace. They carry information that a single left-to-right/right-to-left Boolean would lose.An original data-structure example keeps the stages separate. Represent each stored item by a record containing its logical index, code point, original
Bidi_Class, working directional type, resolved level and eventual visual index. A direction-resolution step can update the working fields while leaving the stored code point and original property intact. A later level-based reordering of bidirectional text step changes position mappings rather than assigning new code points.The advantage appears in debugging a digit within mixed-direction text. Its original classEN identifies a numeric input. Its resolved level describes the computed directional context, and its visual index identifies a placement in one line. Reporting only the visual index would conceal whether a mistake arose during classification, context resolution or final reordering.
The normative property data are supplied by the Unicode character database; broad descriptions such as “a letter in this script” have exceptions. An implementation should use the data for its chosen Unicode version rather than infer every character's class from appearance.[ref]
Unicode Bidirectional Algorithm (Revision 51) by the Unicode Consortium. section3.2: normative character data, exceptions and version-sensitive assignments
Unicode directional control 2026-11-05
A Unicode directional control is a formatting code point that affects bidirectional processing without contributing an ordinary visible letter. Directional marks, embeddings, overrides and isolate delimiters provide different mechanisms within the Unicode Bidirectional Algorithm. They affect interpretation of the stored sequence rather than supplying new letter shapes.[ref]
Unicode Bidirectional Algorithm (Revision 51) by the Unicode Consortium. section2: directional formatting groups and their behavior
Left-to-right and right-to-left marks, LRM (
U+200E) and RLM (U+200F), behave as strong directional items while remaining invisible. A right-to-left isolate initiator, RLI (U+2067), instead starts a bounded bidirectional isolate; PDI (U+2069) terminates it. A mark and a span delimiter therefore carry different structural information.[ref]Unicode Bidirectional Algorithm (Revision 51) by the Unicode Consortium. sections2.4–2.6: isolates, termination and directional marks
An original counting example documents controls by their numerical values. The sequence
U+2066 U+0061 U+0062 U+2069 contains LRI, the two Latin letters a and b, and PDI. It contains four code points and eight UTF-8 bytes: three for each delimiter and one for each Latin letter. Its ordinary visible letters are just a and b. Counting visible letters would therefore lose information about the represented sequence.This notation intentionally shows the control values instead of placing hidden directional formatting characters in the source example. To reproduce an actual layout test, record its logical text order, paragraph direction, Unicode version and line boundaries, then compare the computed bidirectional embedding levels and visual text order.
A higher-level format can express equivalent directional structure through markup. The control-code-point representation and the markup representation need not have the same stored characters even when they request corresponding layout behavior. The specification defines those correspondences, while text shaping remains a further part of rendering.[ref]
Unicode Bidirectional Algorithm (Revision 51) by the Unicode Consortium. section2.7: markup equivalents; section3.5: shaping
Unicode scalar value 2026-11-05
A Unicode scalar value is a Unicode code point other than a surrogate: its numerical value is in
U+0000–U+D7FF or U+E000–U+10FFFF. Unassigned code points and noncharacters in these ranges are still Unicode scalar values; assignment to a written character is a separate property.[ref]The Unicode Standard Version 17 Core Specification. D76 and §3.8, Surrogates
For example,
U+0041 and U+1F600 are Unicode scalar values, while U+D800 is not. In UTF-16, a surrogate pair consists of two code units encoding one Unicode scalar value above U+FFFF. Treating either half as an independent character loses that relationship. UTF-16 2026-11-05
UTF-16 is a Unicode encoding form using sixteen-bit code units. A Unicode scalar value below
U+10000 uses one code unit; a larger one uses a surrogate pair. The surrogate range D800–DFFF is reserved for these pairs and does not itself contain Unicode scalar values.[ref]The Unicode Standard Version 17 Core Specification. §3.9.2, UTF-16 definition and surrogate-pair construction
To encode
U+1F600, subtract hexadecimal 10000, obtaining F600. Split the result into two ten-bit pieces, 003D and 0200; adding D800 and DC00 respectively gives D83D DE00. One represented code point therefore occupies two code units. Counting or cutting sixteen-bit positions can split that pair, while a grapheme cluster can span several code points. The encoding form specifies these numerical units; serialization as bytes additionally requires a byte-order convention.