Hello.
There is a text in my Python script that is in Persian language and the letters are from left to right, but in Persian language letters should be written from right to left.
What should i do now to fix it and print it in UTF-8 format?

The most Pythonic [::-1]
There is also reversed used with join().

Python34 handels Unicode good if you get Persian language correct decoded into Python34.
In Python34 are all strings a sequences of Unicode characters.
Just so you know,there is a big difference between Unicode handling Python 2 and 3.

>>> s = 'ԈԇՄՋֆ'
>>> s
'ԈԇՄՋֆ'
>>> print(s)
ԈԇՄՋֆ
>>> s[::-1]
'ֆՋՄԇԈ'
>>> print(s[::-1])
ֆՋՄԇԈ
>>> print(''.join(reversed(s)))
ֆՋՄԇԈ

Hmm look like Persian character has a problem here.

ԈԇՄՋֆ

Edited 1 Year Ago by snippsat

I'm sorry that I can't answer directly so I suggest you try the main mailing list at or. The people there have forgotten far more than I've ever known about unicode, so I'm certain that you'll get very sound answers :)

This article has been dead for over six months. Start a new discussion instead.