3.1 Synopsis of recode
call
The
general format of the program call is one of:
recode [option]... [charset | request [file]... ]
Some calls
are used only to obtain lists produced by Recode
itself, without actually recoding any file. They
are recognised through the usage of listing
options, and these options decide what meaning
should be given to an optional charset
parameter. See Listings.
In other
calls, the first parameter (request)
always explains which transformations are expected
on the files. There are many variations to the
aspect of this parameter. We will discuss more
complex situations later (see Requests), but
for many simple cases, this parameter merely looks
like this1:
before..after
where before and
after each gives the name of a charset.
Each file will be read assuming it is
coded with charset before, it will be
recoded over itself so to use the charset
after. If there is no file on
the recode command, the program rather
acts as a Unix filter and transforms standard input
onto standard output.
The capability of recoding many files at once is
very convenient. For example, one could easily
prepare a distribution from Latin-1 to
MSDOS, this way:
mkdir package
cp -p Makefile *.[ch] package
recode Latin-1..MSDOS package/*
zoo ah package.zoo package/*
rm -rf package
(In this example, the non-mandatory
‘-p’ option
to cp is for preserving timestamps,
and the zoo program is an archiver
from Rahul Dhesi which once was quite popular.)
The filter
operation is especially useful when the input files
should not be altered. Let us make an example to
illustrate this point. Suppose that someone has a
file named datum.txt, which is almost a
TeX file, except that diacriticised characters are
written using Latin-1 . To complete the
recoding of the diacriticised characters
only and produce a file datum.tex, without destroying
the original, one could do:
cp -p datum.txt datum.tex
recode -d l1..tex datum.tex
However,
using recode as a filter will achieve
the same goal more neatly:
recode -d l1..tex <datum.txt >datum.tex
This
example also shows that l1 could be
used instead of Latin-1; charset names
often have such aliases.
|