2

I need to format a luit command so I can write a file that I'm trying to fix the encoding for. What I have right now is luit -encoding gbk cat santi.txt, but I would like this to have the output written in a text file.

Backstory, I am having trouble reformatting a text document that was originally Chinese characters. For whatever reason using programs such as Notepad++ and encoding websites both have not worked, and I've received error messages trying to use each of the Linux solutions offered here. I turned to luit because I've had some success using it as described here.

Anyways, the luit -encoding gbk cat santi.txt successfully outputs Chinese characters into my terminal. However, it only has an output of ~200 lines, and the file is perhaps 2,000 +.

Looking at the what looks like the luit manual, the two options below seem the most promising.

-ilog filename
Log into filename all the bytes received from the child.
-olog filename
Log into filename all the bytes sent to the terminal emulator.

P.S According to chardef original encoding of the file is probably GB2312.

dylankb
  • 123
  • 3

1 Answers1

1
luit -c <infile >outfile

the -c switch makes luit act like as a simple interpreter from stdin to stdout without its wrapping a child (your shell by default) in a pty and handling its i/o instead.

if you also do:

luit -olog /dev/tty -c <infile >outfile

luit will write to both your terminal and the outfile.

basically the -olog switch will log to a named file a copy of all that luit writes to its output as it writes it - and so it represents luit's processed input, but -ilog would do the same for all of luit's preprocessed input.

mikeserv
  • 57,448
  • 9
  • 113
  • 229
  • 1
    Thanks for the explanation. For future reference the command that worked to simply write a file with the correct encodings was `luit -encoding gbk cat new_santi.txt` – dylankb Dec 18 '15 at 19:39