Right-to-Left Text Converter
Convert LTR text to RTL with Unicode bidi markers, bracket mirroring, and visual reordering. Supports RLM, RLE, RLI embedding modes.
About
Text directionality errors cause layout corruption in multilingual interfaces. When left-to-right (LTR) strings are injected into right-to-left (RTL) contexts without proper Unicode Bidirectional Algorithm markers, punctuation migrates, numbers detach from their labels, and paired delimiters like ( and ) appear inverted. This converter applies UAX #9 embedding controls - U+200F (RLM), U+202B (RLE), and U+2067 (RLI) - to reorder text for RTL paragraph contexts. It also mirrors bracket pairs per the Unicode BidiMirroring.txt specification. The tool does not transliterate; it restructures directionality metadata.
Incorrect bidi handling is a common source of bugs in web applications serving Arabic, Hebrew, Persian, or Urdu content. Misplaced parentheses in legal documents or financial statements can alter meaning. This tool approximates correct visual output assuming a base RTL paragraph direction. Pro Tip: always test converted output in the actual rendering engine (browser, PDF viewer) since bidi resolution depends on the embedding context and font support.
Formulas
The Unicode Bidirectional Algorithm (UAX #9) determines display order through embedding levels. Each character carries an intrinsic bidi class (bc). Strong classes (L, R, AL) anchor direction. Weak classes (EN, AN, ES) inherit from context. Neutral classes (ON, WS) resolve based on surrounding strong types.
where base_level = 0 for LTR paragraphs and 1 for RTL paragraphs. Even embedding levels render LTR; odd levels render RTL.
Bracket mirroring applies the mapping function:
where BidiMirroring is the Unicode consortium's canonical mirror pair table. This converter implements four modes: REVERSE (simple character reversal per line), RLM (prepend U+200F to each line), RLE (wrap with U+202BโฆU+202C), and RLI (wrap with U+2067โฆU+2069, the modern recommended approach). Bracket mirroring is applied in REVERSE mode only, since marker-based modes let the rendering engine handle mirroring.
Reference Data
| Unicode Code Point | Name | Abbreviation | Bidi Category | Effect |
|---|---|---|---|---|
| U+200F | Right-to-Left Mark | RLM | R | Invisible strong RTL character; forces adjacent neutrals to resolve as RTL |
| U+200E | Left-to-Right Mark | LRM | L | Invisible strong LTR character; forces adjacent neutrals to resolve as LTR |
| U+202B | Right-to-Left Embedding | RLE | Embedding | Opens an RTL embedding level; deprecated in favor of isolates |
| U+202A | Left-to-Right Embedding | LRE | Embedding | Opens an LTR embedding level |
| U+202C | Pop Directional Formatting | Terminator | Closes the most recent RLE, LRE, RLO, or LRO | |
| U+2067 | Right-to-Left Isolate | RLI | Isolate | Opens an RTL isolate scope; recommended over RLE |
| U+2066 | Left-to-Right Isolate | LRI | Isolate | Opens an LTR isolate scope |
| U+2069 | Pop Directional Isolate | PDI | Terminator | Closes the most recent RLI, LRI, or FSI |
| U+202D | Left-to-Right Override | LRO | Override | Forces all characters to display LTR regardless of bidi class |
| U+202E | Right-to-Left Override | RLO | Override | Forces all characters to display RTL regardless of bidi class |
| U+061C | Arabic Letter Mark | ALM | AL | Strong Arabic-type character; resolves neutrals in Arabic context |
| U+2068 | First Strong Isolate | FSI | Isolate | Auto-detects direction from first strong character in scope |
| U+0028 โ U+0029 | Parentheses Mirror | ( โ ) | ON (Other Neutral) | Mirrored in RTL context per BidiMirroring.txt |
| U+005B โ U+005D | Square Bracket Mirror | [ โ ] | ON | Mirrored in RTL context |
| U+007B โ U+007D | Curly Brace Mirror | { โ } | ON | Mirrored in RTL context |
| U+003C โ U+003E | Angle Bracket Mirror | < โ > | ON | Mirrored in RTL context |
| U+00AB โ U+00BB | Guillemet Mirror | ยซ โ ยป | ON | Mirrored in RTL context |
| U+2018 โ U+2019 | Single Quote Mirror | ' โ ' | ON | Mirrored in RTL context |
| U+201C โ U+201D | Double Quote Mirror | " โ " | ON | Mirrored in RTL context |