print arabic characters

Martin v. Loewis martin at v.loewis.de
Mon Dec 22 21:18:21 CET 2003


Ahmad wrote:

> I am on Linux Redhat9. Terminal used is Konsole. I am not really sure
> if the terminal should be the one re-arranging the chars?! The konsole
> people say it should be the application programmer to arrange the bidi
> chars correctly!

I believe this is non-sense. It would mean that the program needs
to output the characters in non-logical order, which makes it impossible
to have cut-and-paste work correctly. So it *must* be the terminal
which implements RTL (it also needs to implement glyph shaping).

There are patches circulating that enhance terminals, e.g. for xterm:

http://mail.nl.linux.org/linux-utf8/2000-10/msg00140.html

> Also, I hope that my application will be cross-platform, so if there
> is a way that will work with windows please tell me...

I recommend you don't change the application at all. Instead, you should
work with the terminal application developers to make this work.
Unfortunately, there are quite a lot of terminal applications out there
to change.

> Do I need python2.3? I think the one pre-packaged is 2.2

Not really. If you *know* your terminal is UTF-8, you can output
UTF-8 directly. BTW, you can also implement RTL and glyph shaping
in your application if you know the terminal won't do it.

In Python 2.3, you could print Unicode objects directly, without
the need to encode them as UTF-8 first.

> Also, how do I print "(U+U200F)"?

print u"\u200F".encode("utf-8")

HTH,
Martin





More information about the Python-list mailing list