Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a fresh Ubuntu install and I want to connect over ssh in a gnome-terminal. The server uses latin1 (All files etc. are latin1), so I want to use that in the session. I have changed the charset in the menu-option so that characters are output correctly to my screen, but I can't input non-ascii correctly. Should I pass some magic arguments to ssh or is there a setting in gnome-terminal, or should I use stty? I'm a bit lost.


OK. I have now narrowed the problem down a bit. If I run the following on the command line:

php -r 'while ($c = fread(STDIN, 1)) { echo $c; }'

And press a non-ascii key, it echoes out correctly. However, if I type the same key in the shell, nothing happens. So this must be some setting in the shell environment (Locale setting?). Any ideas?

share|improve this question
up vote 3 down vote accepted

The problem most likely has to do with readline, which bash uses. Put the following in either /etc/inputrc or ~/.inputrc:

set meta-flag on
set output-meta on
set convert-meta off

meta-flag enables eight-bit input (that is, it will not clear the eighth bit in the characters it reads), regardless of what the terminal claims it can support. output-meta will enable the display of characters with the eighth bit set directly rather than as a meta-prefixed escape sequence. When convert-meta is on, readline converts characters with the eighth bit set to an ASCII key sequence by stripping the eighth bit and prefixing it with an escape character (in effect, using escape as the meta prefix). We turn it off. Do man readline for more information about these and other variables.

share|improve this answer
Whoohoo .. That was it. Thanks a bunch - This has been haunting me for weeks. – troelskn Sep 18 '09 at 6:34

You can change the encoding under Terminal->Encoding on the menu in gnome-terminal. Add the Western (ISO 8859-1) encoding, then switch to it.

share|improve this answer
That changes the display (output), but not the input. I see characters correct, but if I press a key with non-ascii characters, it acts weird. – troelskn Sep 11 '09 at 14:15
troelskn, both input and output work for me. My version of gnome-terminal is 2.22.3. – Vebjorn Ljosa Sep 11 '09 at 15:45
Thanks, but the problem seems to be related to the remote shell somehow. I've updated my question. – troelskn Sep 17 '09 at 14:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .