Numbers and Latin-script runs remain left-to-right inline
Aliases: bidi text · mixed-direction text · LTR inline run
What it is
Bidirectional inline text, usually abbreviated BiDi, has a right-to-left base direction while containing characters with different directional properties. Latin letters usually form strong left-to-right runs; digits are weak types whose display levels are resolved by the bidirectional algorithm. URLs, paths, and code also contain substantial punctuation and are not inherently one stable left-to-right run. Direction changes visual ordering, not the logical storage order of characters.
Why it happens
The Unicode Bidirectional Algorithm resolves embedding levels from paragraph direction, strong characters, weak types such as numbers, neutrals, isolate boundaries, and paired-bracket rules; those levels determine display order. Digits generally remain readable internally, but signs, currency marks, slashes, and brackets have distinct classes, so an identifier at a direction boundary can split visually in unexpected ways. String reversal, inserted spacing, and directional overrides detach display from logical data and can break cursor motion, selection, copying, parsing, and assistive reading.
Where it stops holding
Stable digit order does not detach a complete numeric expression from context. Currency marks, signs, percent marks, separators, and units are localized and also participate in bidi resolution; Arabic contexts may use different digit sets. Rich markup, plain-text interchange, and source code provide different controls. Invisible bidi controls can also make the displayed order of code or identifiers differ from logical order, enabling spoofing, so isolation does not replace inspection of untrusted text.
Applying it
- Rely on the platform's Unicode BiDi implementation; never reverse strings or use spacing or overrides to force appearance.
- In HTML-like rich text, prefer semantic markup and CSS: isolate unknown-direction dynamic content with automatic direction, and explicitly mark known identifiers. Use Unicode isolate controls for plain-text interchange where markup is unavailable.
- Test usernames, phone numbers, URLs, paths, and code as complete units; punctuation does not guarantee that they form one stable left-to-right run.
- Format dates, money, and units with locale-aware libraries before embedding the complete result.
- Test cursor movement, selection, copying, pasting, and screen reading inside real RTL sentences, including brackets, slashes, signs, and both sentence edges; inspect untrusted bidi controls as a security case.
Related
- Same group: S1.02.1 Mirroring applies to layout and direction, not every graphic · S1.02.2 Icons expressing time and progress need mirroring · S1.02.3 Icons with physical direction should not be mirrored · S1.02.5 Motion and gesture directions must be mirrored together
- Adjacent: S2.01 Date and time formats · S2.02 Numbers, decimals, and grouping separators
- Search terms:
Unicode Bidirectional Algorithm·bidi isolation·paired bracket algorithm