I am logged into a Mac, running Terminal, ssh'ed into a Linux system and running make
in an emacs window. My error log looks like this:
_raw.cpp:139: error: invalid conversion from âconst char*â to âsize_tâ
_raw.cpp:139: error: initializing argument 2 of âint snprintf(char*, size_t, const char*, ...)â
_raw.cpp:139: error: invalid conversion from âintâ to âconst char*â
_raw.cpp:139: error: initializing argument 3 of âint snprintf(char*, size_t, const char*, ...)â
Notice that apparently GCC is trying to use the unicode smartquote characters, but they are being sent as UTF-8 and Emacs is intercepting them. I think that the problem here is that EMACS needs to pass the UTF-8 generated by the subprocess through to the Terminal. Any idea how to make that happen?
Best Answer
The remote host doesn’t know that your terminal is using UTF-8.
By default, Terminal encodes text as UTF-8, and by default Terminal communicates this to the terminal shell via the
LANG
environment variable (as long as you haven’t changed these preference settings).You can see the encoding (and language) being used with the command
locale
. For example, this is what it says on my Mac:If you run it locally and on the remote host you should see that the remote host doesn’t include “utf-8” in the locale values.
However, prior to Mac OS X Lion 10.7, by default ssh doesn’t communicate the
LANG
environment variable to the remote host. You can arrange for this, but it requires configuring both the ssh client on your Mac to send theLANG
variable and the sshd daemon on the remote host to read it.See the ssh_config and sshd_config man pages on the Mac and the remote host for details. You will probably add a line like
SendEnv LANG LC_*
to the/etc/ssh/ssh_config
file on your Mac andAcceptEnv LANG LC_*
in/etc/ssh/sshd_config
on the remote host (the details may vary on the remote host).Alternatively, you can simply
export LANG="en_US.UTF-8"
once you log in to the remote shell (the exact syntax depends on the remote shell you’re using). Be sure to use the correct language if it isn’t US English (“en_US”). You may also automate this by settingLANG
from within a shell startup script like~/.bash_profile
on the remote host.