|
MediaWiki master
|
Bidi. More...
Public Member Functions | |
| __construct (private readonly Provider $provider,) | |
| Initializes the Bidi handler with the provider. | |
| process (string $value) | |
| Applies bidirectional formatting to the provided text. | |
Public Attributes | |
| const | LRE = "\xE2\x80\xAA" |
| Unicode LEFT-TO-RIGHT EMBEDDING character (U+202A). | |
| const | PDF = "\xE2\x80\xAC" |
| Unicode POP DIRECTIONAL FORMATTING character (U+202C). | |
| const | RLE = "\xE2\x80\xAB" |
| Unicode RIGHT-TO-LEFT EMBEDDING character (U+202B). | |
Bidi.
The Bidi class applies bidirectional formatting to text by wrapping the input with directional isolation control characters. It detects the primary directionality (left-to-right or right-to-left) of the text and ensures that mixed-direction content is rendered correctly.
Usage Example: echo $bidi->process( 'Hello World' );
| Wikimedia\Leximorph\Handler\Bidi::__construct | ( | private readonly Provider | $provider | ) |
| Wikimedia\Leximorph\Handler\Bidi::process | ( | string | $value | ) |
Applies bidirectional formatting to the provided text.
This method determines the primary text direction (LTR or RTL) by examining the first strongly directional codepoint in the string. It then wraps the text with the appropriate directional control characters: LRE and PDF for left-to-right, RLE and PDF for right-to-left. If no strong directionality is detected, the text is returned unmodified.
| string | $value | The text to format. |
Definition at line 72 of file Bidi.php.
References Wikimedia\Leximorph\Handler\Bidi\PDF.
| const Wikimedia\Leximorph\Handler\Bidi::LRE = "\xE2\x80\xAA" |
| const Wikimedia\Leximorph\Handler\Bidi::PDF = "\xE2\x80\xAC" |
Unicode POP DIRECTIONAL FORMATTING character (U+202C).
Definition at line 43 of file Bidi.php.
Referenced by Wikimedia\Leximorph\Handler\Bidi\process().
| const Wikimedia\Leximorph\Handler\Bidi::RLE = "\xE2\x80\xAB" |