[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LANG env var

From: Thomas Dickey
Subject: Re: LANG env var
Date: Wed, 15 Feb 2006 18:17:56 -0500 (EST)

On Wed, 15 Feb 2006, Bob Rossi wrote:

On Wed, Feb 15, 2006 at 01:06:47PM -0500, Thomas Dickey wrote:
On Wed, 15 Feb 2006, Bob Rossi wrote:


Does anyone know if ncurses looks at and uses the LANG environment

yes/no: ncurses expects that the application has called setlocale()
to use the desired locale.  That function takes into account $LANG
and related variables.

OK, I defiantly have not called setlocale (). What is effected if I do
not do that?

It certainly won't recognize UTF-8 - not in 5.5.  In 5.4 I was still
using environment variables to fill in for some lacking functionality
of the runtime library.  But someone pointed out that it had caught up
and I switched to using nl_langinfo() to determine whether UTF-8 applied.

If the locale's not initialized, then ncurses will try to appease some
applications that treat codes 128-255 as "printable".  If the locale is
initialized, it assumes that information is correct.

In particular, I would love it if you could explain how LANG effects an
ncurses program.

It controls the interpretation of whether single bytes with specific
values are printable, whether they can be combined into multibyte
characters (such as UTF-8 encoding).

I have someone reporting this:
I was wondering if it would be hard to fix cgdb to work better
with a UTF-8 code page.  My locale is "en_US.UTF-8" and when I
run cgdb the source file on the top half has a ~� at the left
instead of just a ~.  Not a big deal, but I was just curious
about it.

offhand, google indicates cgdb is a termcap application and is not
relying on ncurses to solve this problem.

What problem? I don't understand how LANG effects ncurses. Could you
explain this?

the problem of determining what's printable, etc.

CGDB does use ncurses to draw to the screen. However, I wrote a custom

ok - I'm not familiar with it (had to google to ask what it's doing ;-)

keyboard input function to capture keys. I look at both the termcap and
the terminfo database to determine what the special key mappings are. I
did this because I need to pass on the raw data to readline in certain
circumstances. Does ncurses provide the application level with the raw
data that made up a particular key?

It can (if keypad() is called with a FALSE).  But that makes reading the
keyboard a lot more work.

And again, is any of this effected by the LANG environment variable?

Sure - the keyboard "should" be able to send multibyte UTF-8 codes
as well as escape sequences for function-keys.  In dialog, I'm using
wget_wch() to read the keyboard and keep track of whether the data
is really function key or some code that happens to be in the range
256-1000 or whatever.

Thomas E. Dickey

reply via email to

[Prev in Thread] Current Thread [Next in Thread]