Skip to content
detect_base_level

detect_base_level

Mojo function 🡭

detect_base_level

fn def detect_base_level(codepoints: List[Int]) -> Int

UAX #9 rules P2/P3, simplified to their common-case outcome: the paragraph’s base embedding level is RTL (1) if the first strongly-directional codepoint is STRONG_R, LTR (0) otherwise (including the case where every codepoint is weak – an all-digit or all-punctuation line has no basis to be anything but LTR).

Args:

  • codepoints (List[Int]): A line’s Unicode codepoints, in logical order.

Returns:

Int: 0 for LTR, 1 for RTL.