Questions tagged [bidi]

Bidi is short for "bi-directional" and means text containing text in both text directionalities, both right-to-left (RTL) and left-to-right (LTR). It generally involves text containing different types of alphabets, but may also refer to boustrophedon, which is changing text directionality in each row. See also the tag `right-to-left`

See also:

Wikipedia: https://en.wikipedia.org/wiki/Bi-directional_text

189 questions
185
votes
7 answers

NameError: global name 'unicode' is not defined - in Python 3

I am trying to use a Python package called bidi. In a module in this package (algorithm.py) there are some lines that give me error, although it is part of the package. Here are the lines: # utf-8 ? we need unicode if isinstance(unicode_or_str,…
TJ1
  • 7,578
  • 19
  • 76
  • 119
35
votes
8 answers

Why words are shuffled when I insert English words in any Arabic/Urdu/Persian text on Notepad or MS Word?

I can write Arabic/Urdu/Persian on MS Word or Notepad just fine, but whenever I insert any English word or number, the sequence is just disturbed and seems like the all the words have been shuffled in the sentence. Look at the example below: یہ ایک…
Arfeen
  • 2,553
  • 5
  • 29
  • 48
31
votes
5 answers

How to detect whether a character belongs to a Right To Left language?

What is a good way to tell whether a string contains text in a Right To Left language. I have found this question which suggests the following approach: public bool IsArabic(string strCompare) { char[] chars = strCompare.ToCharArray(); foreach…
Patrick Klug
  • 14,056
  • 13
  • 71
  • 118
30
votes
4 answers

How to solve BiDi bracket issues?

As you might know some languages are written/read from right to left and we are trying to support some RTL languages. For the web UI using dir="rtl" in html does most of the job thanks to algorithms that browsers have. But I came across this issue…
yusuf
  • 3,596
  • 5
  • 34
  • 39
29
votes
4 answers

How to force a piece of text to be 'direction ltr' inside a 'direction rtl' paragraph

So, phone numbers are always ltr (left to right). Working on a multilingual website I need to insert a phone number (with a '+' prefix and numbers separated by '-') inside a text paragraph that has direction rtl (for relevant languages of course) So…
Jonathan
  • 8,676
  • 20
  • 71
  • 101
24
votes
6 answers

JavaScript: how to check if character is RTL?

How can I programmatically check if the browser treats some character as RTL in JavaScript? Maybe creating some transparent DIV and looking at where text is placed? A bit of context. Unicode 5.2 added Avestan alphabet support. So, if the browser has…
Kryzhovnik
  • 381
  • 1
  • 2
  • 6
21
votes
1 answer

Insert RTL text correctly in PHPWord template

I'm using PHPWord template processor to insert some text in a template. The word template is formatted LTR as all the labels are English. Here is the line in the word template: User Name: ${name} Here is the PHP line that replaces the…
Amr H. Abd Elmajeed
  • 1,521
  • 15
  • 41
19
votes
3 answers

How to get text direction in Android and change layout dynamically according to the direction?

I'm doing some research about feasibility of changing UI dynamically based on direction of a text. Although Google is supporting RTL languages (ref: Native RTL support in Android 4.2) but it doesn't cover a situation that application has mix of LTR…
Hesam
  • 52,260
  • 74
  • 224
  • 365
18
votes
7 answers

How can I automatically set text direction based on input text language?

In Google plus (and a lot of other places), when I want to post something, when I type it in Persian, which is a right-to-left language, text direction is automatically set to rtl and text-alignment:right, and when I start to type in English it…
Mostafa Shahverdy
  • 2,687
  • 2
  • 30
  • 51
14
votes
1 answer

Concatenate left-to-right (LTR) and right-to-left (RTL) text

It seems that combining left-to-right (LTR) and right-to-left (RTL) text using paste can produce unexpected results for the resulting order: (x = paste(c('green', 'أحمر', 'أزرق'), collapse=' ')) # arabic for blue and red #> [1] "green أحمر…
geotheory
  • 22,624
  • 29
  • 119
  • 196
11
votes
3 answers

TypeError: unsupported operand type(s) for +: 'dict_keys' and 'list'

I am trying to use a Python package called bidi. In a module in this package (algorithm.py) there are some lines that give me error, although it is part of the package. Here are the lines: _LEAST_GREATER_ODD = lambda x: (x + 1) |…
TJ1
  • 7,578
  • 19
  • 76
  • 119
10
votes
4 answers

Android mixed language text - BidiFormatter on String with RTL and LTR text

I have a ListView with custom View where I have a TextView :
NickF
  • 5,637
  • 12
  • 44
  • 75
9
votes
4 answers

HTML5 Canvas fillText with Right-to-Left string

I am trying to use the fillText() method on an HTML5 Canvas' 2d Context to draw a string written in Arabic. It works perfectly, until I put a punctuation mark at the end of the string. Then the punctuation mark appears on the wrong side of the…
user1145886
  • 171
  • 2
  • 6
9
votes
2 answers

how to properly concatenate bidi strings in r?

I want to add markup to (Urdu language) text that is written right to left. I am trying to use gsub for the purpose but everything I have tried so far does not produce the desired output text <- "یہ جملہ ایک مثال کے لیے استعمال کیا جا رہا…
Imran Ali
  • 2,223
  • 2
  • 28
  • 41
9
votes
3 answers

Change direction of negative number with combination of LTR and RTL content

Here is my HTML structure: div{ direction: rtl; } span{ direction: ltr; }
امروز -2
This is expected result: As you see, - sign should come in the beginning of the number. How can I do that? Note: The…
Martin AJ
  • 6,261
  • 8
  • 53
  • 111
1
2 3
12 13