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
2
3
luit -encoding <enc> -- prog [args...]  # (1)
prog_outputs_gbk | luit -c -encoding gbk # (2)
luit -encoding <enc> # (3) invokes a nested shell using given encoding

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
2
3
cat | luit -encoding gbk -c >file
# or simpler:
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.