On my Mac terminal, printing UTF-8 works in general, but the less
doesn't work correctly.
So this works correctly:
$ echo -e '\xe2\x82\xac'
€
but piping it into less gives something like this:
$ echo -e '\xe2\x82\xac' | less
<E2><82><AC>
How can this be fixed?
For diagnostics:
I'm using Mac OS 10.6.8. less version 418, Terminal 2.1.2 (273.1).
The output of my locale is this:
$ locale
LANG="en_US.UTF-8"
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL="C"
Okay, I found the answer after some googling. Apparently,
LESSCHARSET
needs to be set like this:Now
less
works fine for me.If you can see some unicode characters in
less
, but are unable to getless
to display emoji, try upgradingless
to a more recent version. On Mac OS X, I went from version 458 to 481 and that fixed my problem (for example,git log
can now display emoji in commit messages).If you have homebrew, you can replace the system less with a newer version by running
brew install homebrew/dupes/less
.Works for me with
I googled this and tried the following environment variables which worked for me:
Seeing as I find the LC_ALL in multiple different answers I think this is the correct one. But maybe not the only right answer, there could of course be more correct answers to this question.
Anyway some more googling gave me this description for the variable:
source: http://pubs.opengroup.org/onlinepubs/007908799/xbd/envvar.html
Leading me to think this is the language variable to rule them all :)
Just update you
[less][1]
Do it with brew.