It looks like it's not possible. As a partial workaround, you may use iconv as an input preprocessor in the following way.
- Create the following executable script, say
less_conv.sh: #!/bin/sh iconv -f $IN_ENC -t $OUT_ENC $1
- Define and export the
LESSOPEN variable: export LESSOPEN="|-less_conv.sh %s"
- Invoke
less this way: IN_ENC=latin2 OUT_ENC=utf8 less somefile
You may also set your preferred values: export IN_ENC=latin2 export OUT_ENC=utf8 less somefile
The pipe character | in LESSOPEN saves the need for a temporary intermediate file. The dash - enables this preprocessor when less reads standard input.
Limitation:
The preprocessor is invoked only once, even if you hit F or R, so you won't be able to use this workaround on growing files or "streaming" standard input.
IN_ENC=latin2 OUT_ENC=utf8 less my_file. Tell me if you want more help I'll try to write an answer.iconv -i latin2 -o utf-8. If you hate the extra buffering, look intostfbuf.-fand-t, respectively.