cstocs1
Reencoding utility
Format
cstocs [ options ] src_encoding dst_encoding [ file ... ]
Overview
Cstocs is a simple utility to change encoding of given text. It takes files [ file ... ] (if none is specified, then it uses standard input), assuming that they are encoded in src_encoding, and tries to reencode it into dst_encoding. Result is written to standard output. I.e., semantics of [ file ... ] is the same as in cat(1).
There are two versions of cstocs in cstocs 3.0 package: cstocs.pl written in Perl 5, and cstocs.awk writen in GNU awk. The install script will link cstocs.pl as csttocs, if perl is present, and cstocs.awk as cstocs otherwise. The cstocs.awk is mostly the same program as cstocs 2.2. See also the BUGS section.
Characters, that are not defined in src_encoding, are passed to standard output unchanged.
If source text contains character, that is defined in src_encoding but not in dst_encoding, it can be handled several ways. For example, character "e with caron" (symbol ecaron), and "d with caron" (symbol dcaron) are included in iso-8859-2 encoding, but not in iso-8859-1. If you will do reencoding of 8859-2 text to 8859-1, you may want to do one of the following actions:
1)-
Do not produce any output instead of "ecaron" symbol.
2)-
Substitute some string (possibly a space) instead of both ecaron and dcaron.
3)-
Substitute a letter "d" instead of dcaron, and "e" instead of ecaron. It is even possible to substitute string instead of symbol, so you can replace the "AE" Latin character with string "AE" (letter "A", and letter "E"). Or you can replace a "plusminus sign" with a string "+/-". These substitutions are described in
accentfile.
Options
-
--dir directory -
Encoding files are taken from directory instead of default /usr/local/lib/cstocs. If CSTOCSDIR environment variable is set, it is used instead. The highest priority has --dir option, next is CSTOCSDIR and if none of the above two is used,
cstocsuses the default directory /usr/local/lib/cstocs.
-
--fillstring string -
If source text contains character, that is defined in src_encoding but not in dst_encoding nor in
accentfile, it is replaced by string. Default action is to replace such a character with space.
-
--null -
Completely equivalent to --fillstring "".
-
--nochange -
Do not look to
accentfile. If you use both --null and --nochange,cstocswill work after the1)scheme. Using --null and --fillstring makescsotcsworking after2)scheme.
-
--onebyone -
Use only these rules from
accentfile, which rewrite symbol to exactly one character. If this option is specified, character "ecaron" will be rewritten to "e", but "AE" character will not be rewritten to "AE" string. This is the default option.
-
--onebymore -
Use all rules from
accentfile.
Available encodings
ascii-
This is 7-bit ASCII encoding. Can be used to strip diacritic from characters.
il1-
ISO-8859-1 (West European languages)
il2-
ISO-8859-2 (East European languages)
cork-
Cork (T1) encoding used by TeX's DC fonts and by LaTeX 2e.
kam-
Kamenicky encoding (it was one of the most popuar encodings in Czech/Slovak language space).
koi-
It is KOI8-cs encoding (very old).
vga-
Encoding used by standard IBM PC vga cards.
pc2-
PC-Latin2 encoding, supported by M$-DOS.
1250-
Encoding used by czech M$-Windows.
1252-
Encoding used by M$-Windows (aka MS-Windows Latin 1).
mac-
Macintosh Roman encoding.
macce-
Macintosh Central European encoding.
The name of the game
Name cstocs is an acronym of `czech+slovak to czech+slovak'. This name is stolen from cstocs.exe utility, which was used for similar purposes under M$-DOS.
Examples
- cstocs il2 ascii myfile.8859-2 | lpr -Pmatrix
-
Sends iso-8859-2 encoded text to a ASCII matrix printer.
- cstocs kam il2 <mytext.kam >mytext.8859-2
-
Translate old text into a "standard" iso-8859-2 encoding.
- cstocs --null --nochange koi8 ascii file1 file2 >ascii.file
-
Takes a koi8-encoded files and deletes are characters which are in koi8-cs but not in 7-bit ASCII.
Files
/usr/lib/cstocs/accent
/usr/lib/cstocs/*.enc
Environment
CSTOCSDIR