public static class BidiAlgorithmThe Unicode bidirectional algorithm, UAX#9.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Text is stored in the order it is read and drawn in the order it is seen, and for Arabic and Hebrew those are not the same. Worse, they are not the same for the English in an Arabic sentence either: a phone number inside a right-to-left paragraph runs left to right inside a right-to-left run, and the brackets around it swap which way they point. Nothing about this can be approximated — a paragraph is either laid out correctly or it is gibberish to the person reading it.
The algorithm has four phases and each is a different shape of problem. Explicit levels (X1–X8) are a stack machine over embedding and isolate controls. Isolating run sequences (BD13) chop the paragraph into the units everything after works on, and getting them wrong makes every later rule look broken. Resolution (W, N, I) is a series of passes that rewrite types in place. Reordering (L) turns levels into an order by reversing runs from the deepest level up.
Judged by 91 707 of the Consortium's own cases, which is the only sane way to write this.
Fields and properties (1)
public const int MaximumDepthThe deepest an embedding can go. UAX#9's, and it is not negotiable.
Methods (2)
public static BidiResult Resolve(ReadOnlySpan<int> codePoints, ParagraphDirection direction = Auto)Runs the algorithm over a paragraph.
public static BidiResult Resolve(string text, ParagraphDirection direction = Auto)Runs the algorithm over a string.
Used by (4)
- BidiConformanceTestsVixen.Ui.Text.Tests
- BidiStateVixen.Ui.Text
- BidiTestsVixen.Ui.Text.Tests
- TextItemizerVixen.Ui.Text