# ncurses, char encoding and remote shell



## freethread (Jul 7, 2010)

I cannot configure some console based applications to right display character in UTF-8.

In my login script for tcsh I inserted an if/else statement to set different char encoding:


```
if ( "$TERM" != "cons25" ) then
   setenv LANG      it_IT.UTF-8
   setenv LC_ALL    it_IT.UTF-8
else
   setenv LANG      it_IT.ISO8859-1
   setenv LC_ALL    it_IT.ISO8859-1
endif
```

this code set ISO8859 when log on the computer keyboard/monitor and UTF-8 when in remote with rlogin (PuTTY, TeraTerm, etc.). In remote the $TERM var is set to one of 'xterm', 'screen', 'putty'. (Yes, if logged on computer keyboard/monitor and run 'screen' the previous code set UTF-8 and the encoding is wrong, but this is not a problem, normally I run 'jfbterm', the problem is only in remote). 

Here are some screenshots using PuTTY (actually I only use it in remote console) and some
programs running in it.






Running 'sysinstall' at prompt






Running 'sysinstall' in 'Tmux'






Running 'sysinstall' in 'GNU screen'​
As you can see when running in 'GNU screen' box-drawing characters are correctly displayed, this appens with or without the 'GNU screen' -U switch

PuTTY really run in UTF-8 mode as you can see in the following screenshots (menu item 'ModalitÃ  lista') the 'Ã ' character is correctly displayed. I tested it printing the UTF-8 sequence of semigraphics characters and they print correctly (3 bytes) but it seems that ncurses work in an understandable mode.





Midnight Commander at prompt






Midnight Commander in 'GNU screen'​
Any comment, suggestion, exclamation?


----------



## itcotbtoemik (Jul 21, 2010)

PuTTY and screen diverge from VT100-compatibility by ignoring the VT100 line-drawing
controls when in UTF-8 mode.  There's a work-around in ncurses, by setting an
environment variable (NCURSES_NO_UTF8_ACS), documented in the ncurses manpage.


----------



## freethread (Jul 22, 2010)

It works! itcotbtoemik, you are a wizard.

[CMD=""]setenv NCURSES_NO_UTF8_ACS 1[/CMD]

What changed:

midnight commander: ok
cdialog: ok
dialog: ok, use alternative ('+' '-' '|')
perl + p5-Curses + p5-Curses-UI: ok, use alternative

This was not a big problem, in mc the *-a* switch and in cdialog the *--ascii-lines* or *--no-lines* switch use the alternative line drawing characters or spaces.

Many scripts/programs do not care of how the line drawing chars are displayed, have no switches to enable/disable. Sometimes reading the text inside boxes with 'qqqqqqqqqqqqqqq' is confusing.

PS: definitively I set TERM env var to 'xterm' for 'the universe' (PuTTY, GNU Screen, Tmux, etc.). The images in previous post show behaviours with TERM set to 'xterm'.


----------

