Is the Python binding for ncurses unicode capable?

Thomas Dickey dickey at saltmine.radix.net
Fri Jan 20 12:07:59 CET 2006


"Martin v. Löwis" <martin at v.loewis.de> wrote:
> Thomas Dickey wrote:
>>>ncurses expects byte strings (although I'm uncertain as to what
>>>impact multi-byte encodings have in ncurses).
>> 
>> 
>> It depends on whether python's curses binding is linked with the wide-character
>> flavor (ncursesw) or the normal one.  If it's linked with ncursesw, strings are
>> interpreted according to the locale settings.

> Are you sure? According to ncurses' INSTALL file, the purpose of
> ncursesw is to provide wide character support, not locale support.
> It's two libraries just for binary compatibility issues.

Well, of course I'm _sure_.  But my explanation may be poor.

Both libraries respond to locale.  But ncurses only deals in single-byte
encodings, e.g., ISO-8859-1 through ISO-8859-15.  ncursesw supports that,
but adds support for multi-byte encodings, e.g., UTF-8.  For the latter,
one can also have characters that combine (a printable character combined
with other characters that overlay it or combine to form a new character).

ncurses stores the character data in one byte per cell.
ncursesw requires more than one byte per cell.
That's the reason for two libraries.

But since ncurses (not ncursesw) doesn't know about multibyte encoding,
it can't do anything related to the locale for those.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net



More information about the Python-list mailing list