Reputation: 55
I am trying to print Urdu words using python. I read about Unicode but the [problem I face is that python tries to print the Urdu just like English, that is, from left to right and character by character. In Urdu characters] cannot be printed like those in English. I have already tried few solutions like the one mentioned here but they didn't work for me. I have been trying to print my Urdu string with the following code.
text_string = "آکاش کمار".decode('utf-8')
print text_string
the output I get on Ubuntu terminal is like English from left to right instead of right to left and that too character by character.
Upvotes: 2
Views: 1669
Reputation: 1
by using LibRaqm your problem can be solved the link to the library is given below https://github.com/HOST-Oman/libraqm
Upvotes: 0
Reputation: 50819
I believe the problem is with Gnome Terminal which does not support bidirectional (i.e., right-to-left or "RTL") text output. If I run your above program (with an encoding declaration):
# -*- coding: utf-8 -*-
text_string = "آکاش کمار".decode('utf-8')
print(text_string)
in an Emacs shell buffer (with does support mixed LTR and RTL output), I get the correct output:
$ python2 urdu.py
آکاش کمار
$
However, if I run it in a Gnome Terminal, I get the backwards output that you posted.
If you don't use Emacs, another alternative is to install the mlterm
(multilingual terminal) package and use the terminal emulator it provides.
Upvotes: 2