Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ACS characters not working in putty even with export NCURSES_NO_UTF8_ACS=1

Tags:

c

ncurses

I am developing an ncurses application myself in C. The problem is that putty displays alternative character set characters like ACS_VLINE as letters. My locale is

LANG=en_US.UTF-8

and I have set

export NCURSES_NO_UTF8_ACS=1

I have also set putty to UTF-8 and tried different fonts. The characters display fine on the tty on the actual machine so I think the issue is with putty. I have also tried linking ncursesw instead of ncurses.

like image 513
Will Avatar asked Jun 15 '16 20:06

Will


1 Answers

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
like image 137
Thomas Dickey Avatar answered Oct 05 '22 19:10

Thomas Dickey