How to make the ‘less’ command handle UTF-8

mac-osxterminalunicodeutf-8

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"

Best Answer

Okay, I found the answer after some googling. Apparently, LESSCHARSET needs to be set like this:

export LESSCHARSET=utf-8

Now less works fine for me.