What is BiDi (Bidirectional Text)?
Bidirectional (BiDi) text mixes right-to-left and left-to-right content in one string: an Arabic sentence containing an English product name, a Hebrew UI showing a file path, a phone number inside Persian text. The display order of such text is decided by the Unicode Bidirectional Algorithm, which reorders runs of characters based on their direction properties and the surrounding context.
BiDi bugs are notorious because the stored string is correct while the rendered string looks scrambled: punctuation jumps to the wrong end, or a neutral character like a slash attaches to the wrong run. Interpolated values are the classic trigger, since a placeholder filled with LTR text inside an RTL sentence inherits ambiguous context.
The fix is isolation. HTML offers the bdi element and dir="auto"; Unicode offers invisible control characters (the isolate marks FSI, LRI, RLI, PDI) for plain-text contexts. Wrapping user-supplied or interpolated values in an isolating construct keeps their direction from leaking into the surrounding sentence.
{{-- Isolate an interpolated value inside RTL text --}}
<p dir="rtl">
{{ __('messages.uploaded_by') }} <bdi>{{ $user->name }}</bdi>
</p>