Skip to content

Instantly share code, notes, and snippets.

@Bramengton
Created January 23, 2019 11:52
Show Gist options
  • Select an option

  • Save Bramengton/d9afa10b994e55ca09adbd43b41ef7c7 to your computer and use it in GitHub Desktop.

Select an option

Save Bramengton/d9afa10b994e55ca09adbd43b41ef7c7 to your computer and use it in GitHub Desktop.
RTL -> LTR -> RTL
LTR We will send an SMS with a confirmation code to your phone number: %s
On screen: We will send an SMS with a confirmation code to your phone number: +380123456789
RTL \u202Cאנו נשלח הודעת SMS עם קוד אישור למספר הטלפון שלך:\u202A %s
You can embed bidi regions using unicode format control codepoints:
Left-to-right embedding (U+202A)
Right-to-left embedding (U+202B)
Pop directional formatting (U+202C)
So in java, to embed a RTL language like Arabic in an LTR language like English, you would do
myEnglishString + "\u202B" + myArabicString + "\u202C" + moreEnglish
and to do the reverse
myArabicString + "\u202A" + myEnglishString + "\u202C" + moreArabic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment