How do I connect from a utf-8 client to a latin1 server over ssh?

2

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.

Update:

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?

troelskn

Posted 2009-09-11T09:30:33.717

Reputation: 371

Answers

3

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.

Vebjorn Ljosa

Posted 2009-09-11T09:30:33.717

Reputation: 1 441

Whoohoo .. That was it. Thanks a bunch - This has been haunting me for weeks. – troelskn – 2009-09-18T06:34:28.683

2

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.

Vebjorn Ljosa

Posted 2009-09-11T09:30:33.717

Reputation: 1 441

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 – 2009-09-11T14:15:28.747

troelskn, both input and output work for me. My version of gnome-terminal is 2.22.3. – Vebjorn Ljosa – 2009-09-11T15:45:26.773

Thanks, but the problem seems to be related to the remote shell somehow. I've updated my question. – troelskn – 2009-09-17T14:48:19.960