luit Usage
luit can translate non-UTF-8 char encodings into UTF-8, but cannot do the reverse. There're many ways to invoke luit, first read the manual.
1 | luit -encoding <enc> -- prog [args...] # (1) |
The limitation of usage (1) is if the program also redirects its output, it's tricky:
You hope this would writes GBK chars into file
, but it doesn't. What you types
is repeated to the stdout. Because luit merely runs cat
, not cat >file
.
1 | luit -encoding gbk cat >file |
Also, this won't work either:
1 | cat | luit -encoding gbk -c >file |
-c
makes luit
take from stdin and writes to stdout. It doesn't work b/c luit
translates gbk to utf8, from stdin to stdout. If you want the file
to have gbk
content, it won't work.
Finally, to make it work:
1 | luit -encoding gbk sh -c 'cat >file' |
or run luit -encoding gbk
which opens a nested shell, then in that shell, do
cat >file
.