Is the Python binding for ncurses unicode capable?
"Martin v. Löwis"
martin at v.loewis.de
Thu Jan 19 14:31:21 EST 2006
Brian McNally wrote:
> Thanks for responding to my question. I'm still a little confused
> though. How can I encode unicode strings as UTF-8? My terminal does
> support UTF-8, but from looking at Python's ncurses API, it looks like
> all of the methods for displaying characters want an ASCII code (which
> seems to be an integer between 0 -255).
If u is a Unicode string, you do
s = u.encode("UTF-8")
to get a byte string s.
You are mistaken assuming that the ncurses API requires ASCII, and you
are mistaken assuming ASCII is a sequence of integer values 0..255.
ASCII (the American Standard Code for Information Interchange) is
encoded using a sequence of bytes in the range 0..127.
UTF-8 is encoded using a sequence of bytes in the range 0..255
(as is Latin-1, windows-1252, and any other character encoding/charset).
ncurses expects byte strings (although I'm uncertain as to what
impact multi-byte encodings have in ncurses).
Regards,
Martin
More information about the Python-list
mailing list