2

I need to create a table in reportlab with text in RTL languages like Arabic and Hebrew as well as LTR languages such as English.

Following to this post, I'm adding the Unicode Character 'RIGHT-TO-LEFT EMBEDDING' (U+202B) at the beginning of each Arabic/Hebrew word, and the Unicode Character 'POP DIRECTIONAL FORMATTING' (U+202C) at the end of each word.

So the Arabic word 'مرحبا' will be like this:
u'\u202B\uFEE3\uFEAD\uFEA4\uFE92\uFE8E\u202C'

And similarly the Hebrew word 'שלום' will be like this:
u'\u202B\u202E\u05e9\u05DC\u05D5\u05DD\u202C'

Unfortunately, in my table in the reportlab produced PDF, the word still comes out reversed: 'ابحرم' and 'םולש'

(Nb. I also tried adding the Unicode Character 'RIGHT-TO-LEFT MARK' (U+200F) before the RTL characters, like this: print u'\u200F\uFEE3\uFEAD\uFEA4\uFE92\uFE8E' following this post But the result is the same :()

Also when I use ipython to print this unicode string, the text will come out reversed:

print u'\uFEE3\uFEAD\uFEA4\uFE92\uFE8E' ابحرم print u'\u202B\u202E\u05e9\u05DC\u05D5\u05DD\u202C' םולש

How can I get the Arabic and Hebrew text come out right?

Nb. I checked PythonBidi and PyFriBidi, but I don't want to use these libraries.

Kemeia
  • 826
  • 2
  • 9
  • 24
  • I am not at all knowledgeable in the subject of language encodings, but I did run across [this](https://superuser.com/a/1236049/501265) answer to (I think) a similar question a few days ago. – Aaron Aug 07 '17 at 14:54
  • Thanks Aaron! I understand why the letters are turned around, but I don't get why adding the right-to-left embedding character doesn't fix it. Unfortunately, also adding the right-to-left mark character as suggested in the post you referred to doesn't help. There is something I'm doing wrong but I can't figure out what. – Kemeia Aug 07 '17 at 15:03
  • ReportLab does not natively support complex text layout, you really do need the extra library. Background http://two.pairlist.net/pipermail/reportlab-users/2015-September/011444.html – bobince Aug 07 '17 at 17:03
  • Thanks bobince And what about the print in iptyhon? Why doesn't it reverse the letters as I would expect? – Kemeia Aug 07 '17 at 17:40
  • I am not a `python` developer but I know that some tools omits rtl-ltr related characters as they does not present at all. The tool, here the PDF generator, must support `rtl` separately. – Afshar Mohebi Oct 14 '17 at 11:17

0 Answers0