Edit: I should have mentioned in my original question that I was using MacPorts SSH client, as it turned out there were two root causes. See my own answer below.
When I SSH into my OSX machine, it's not setting the locale properly:
LANG= LC_COLLATE="C" LC_CTYPE="C" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL=
This should be using a UTF-8 locale. It should look like this:
LANG="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_CTYPE="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_ALL=
I'm running OSX 10.11.6 (El Capitan), and I've enabled the SSH server in System Preferences.
I'm using putty as a client on my Windows machine. When I use the same putty configuration to connect to a Linux server, the locale information is fine.
When I run a local terminal on the OSX machine, locale is fine. If I then
ssh localhost, I have the same problem: no locale is set.
It seems that my OSX SSH server is ignoring or discarding the locale information from the client. I have the following in my (unmodified)
AcceptEnv LANG LC_*
To the best of my knowledge, that's all that's required.
My putty configuration is sending
TERM=xterm-256color, which is being honored; it's only the locale information that isn't working, and to reiterate, it happens when I
ssh localhost from OSX to itself, so I don't think putty is the issue here.
I will not accept answers that suggest setting the locale in my
.profile; there are plenty of answers on here suggesting that, but it's a hack, not a solution.