ACS characters not working in putty even with export NCURSES_NO_UTF8_ACS=1
It is a combination of things. The recommended TERM
for PuTTY is "putty", but due to inertia, most people use "xterm". The line-drawing support in the xterm terminal description is different from PuTTY's assumptions because xterm supports luit, which has some limitations with the way the alternate character set is managed (see Debian Bug report #254316:
ncurses-base: workaround for screen's handling of register sgr0 isn't quite right).
If you use infocmp
to compare, you may see these lines which deal with the alternate character set:
acsc: '``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~', '``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~'.
enacs: NULL, '\E(B\E)0'.
rmacs: '\E(B', '^O'.
smacs: '\E(0', '^N'.
VT100s can have two character sets "designated", referred to as G0 and G1:
- The "xterm" line-drawing works by changing the designation of G0 between the ASCII and line-drawing characters,
- the "putty" line-drawing works by designating ASCII in G0 and line-drawing in G1 and switching between the two with the shift-in/shift-out control characters.
Although both are VT100-compatible, the xterm scheme does not work with PuTTY. Because of the tie-in with luit
, the normal terminal description for xterm
will not change (unless it proves possible to modify luit
to solve the problem for its users), so a workaround is needed for users of PuTTY:
use a different terminal description as recommended, e.g.,
TERM=putty
. PuTTY's settings dialog lets you set environment variables to pass to the remote machine.This has the drawback that some systems do not have the full ncurses terminal database installed, due to "size" (it is 6.8Mb on my local machine). Also,
TERM
may not be on the list of allowed ssh environment variables.you can compile your own terminfo entry with ncurses' tic, e.g.,
cat >foo <<"EOF" xterm|my terminfo entry, enacs=\E(B\E)0, rmacs=^O, smacs=^N, use=xterm-new, EOF tic foo
use GNU screen. It does its own fixes, and happens to compensate for PuTTY's problems.
Further reading
- SCS – Select Character Set (VT100 manual)
- 4.4 Character Set Selection (SCS) (VT220 manual)
- The terminfo database is big—do I need all of that? (ncurses FAQ)
- Putty: login, execute command/change environment variable, and do NOT close the session
I want to make some additions. I faced same issue: many ncurses-based tools like dialog
, menuconfig
and nconfig
from Linux kenrel sources, even mc
is broken when built with ncurses (although mc
is built using Slang on many OSes and not affected).
Here is what happened
ncurses uses smacs
record from terminfo to switch to "alternative charset" and then it uses acsc
to draw boxes. It sends a
which is box-drawing character in alternative charset (ACS).
This is VT100 graphics.
Some terminal emulators nowadays do not support ACS when in UTF-8 because apps have ability to send real box-drawing codepoints.
There is unofficial capability U8
(capital U!) in terminfo
that tells ncurses: "Instead of ACS use real box-drawing codepoints."
I have this capability infocmp -x xterm-utf
and for putty aswell, but not for xterm
.
As you can read in ncurses(3)
(https://invisible-island.net/ncurses/man/ncurses.3x.html), ncurses
is aware of Linux console and GNU screen (and tmux, which also uses screen
as TERM
) and always behave like if U8
were set.
For other terminals that do not support ACS when in UTF, you can set NCURSES_NO_UTF8_ACS
.
Unfortunatelly, ncurses is not aware of putty.
There is also luit
that may convert ACS to Unicode points.
So, here is what we can do to run ncurses + putty in UTF-8:
Use terminal with
U8#1
capability. This one is set for putty (btw, I suggest to useputty-256color
instead). You can create your own entry withU8#1
andcolors#256
and compile it withtic -x
. Be carefull that mouse may not work on terminals that do not start withxterm
(seemouseinterval(3)
, BUGS section). This is why I do not useputty
terminal. I suggest to copyxterm-utf8
, addcolors#256
, compile and stay with it: it works perfectly with putty, mouse and utf8.You can set
NCURSES_NO_UTF8_ACS
in your profile.You can run
screen
ortmux
: it will setTERM
toscreen
and fixncurses
You can run
luit
: it will do all convertions for you.Since putty 0.71 you can ask putty to support ACS drawings even in UTF-8