Less in cygwin can't read file created from redirected windows cmd script

1

I'm running windows cmd script from windows console and redirecting output to a file by mycommand.cmd > 'filename ' 2>&1 the problem is, when I'm trying to read that file using less under cygwin, it says that file may be a binary and then can't detect encoding. I can open and see file correctly if I open it through, say, notepad++, it shows that file has USC-2 (BE) encoding. Is there a way to make less to understand file and display it correctly?

dhblah

Posted 2013-10-28T13:20:35.660

Reputation: 153

Answers

0

If the output is expected to be mostly ASCII, you can just delete the NULs with

tr -d '\0'

You could probably try to see if $LANG can be set to an UTF-16 locale, but I'm not really sure and I don't have a cygwin install at hand to try it; otherwise you can use iconv(1) to do the conversion, set $LANG to some sane value (ie an utf8 locale) and enjoy.

loreb

Posted 2013-10-28T13:20:35.660

Reputation: 101