---
name: "cstocs"
section: "1"
platform: "linux"
package: "cstocs"
version: "3.0-3"
release: "Debian 1.3 (Bo)"
platforms: ["linux"]
url: "https://new.carta.tech/cstocs"
---

# cstocs(1)

reencoding utility

## NAME

cstocs - reencoding utility

## FORMAT

**cstocs** \[ options \] src\_encoding dst\_encoding \[ file ... \]

## DESCRIPTION

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)](/cat/1.md).

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 **accent** file.

## 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, **cstocs** uses 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 **accent** file, 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 **accent** file. If you use both *--null* and *--nochange*, **cstocs** will work after the **1)** scheme. Using *--null* and *--fillstring* makes **csotcs** working after **2)** scheme.

- *--onebyone*

  Use only these rules from **accent** file, 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 **accent** file.

## 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

## SEE ALSO

[gawk(1)](/gawk/1.md), [ascii(7)](/ascii/7.md), [cat(1)](/cat/1.md)

ftp://toy.zcu.cz/pub/kiv-local/luki/published/cs-encodings-faq

FILE.FORMAT in cstocs distribution

## AUTHORS

Jan "Yenya" Kasprzak \<kas@muni.cz\>

Some tables were contributed an corrected by Jan Pazdziora \<adelton@fi.muni.cz\>

The mac, macce and 1252 tables, as well as some bug fixes were contributed by Jiri Kvarda \<kvarda@vc.cvut.cz\>

Many people on the Net sends me fixes for the encoding tables.

## BUGS

cstocs.awk is written in [**gawk**(1)](/gawk/1.md). It was developed using GNU gawk 2.15. I am not sure, if it uses any gawk-specific stuff. If you see the "syntax error" message from awk, you should get and use GNU awk or nawk.

- cstocs.awk appends newline at the end of output file, even if the input

  file's last line does not end with a newline.

- cstocs.awk is a terribly slow. This is probably because gawk uses

  FP arithmetic even for integers. On my machine the Perl version was 45-times faster than the AWK version in the default case and more than 2-times faster in --onebymore case.

- Man page an option names can be confusing :-(

  ## BUG REPORTS

If you will have any problem with this software, do:

- 1\) RTFM,

  - 2\) if this does not help you, feel free to send me mail to \<kas@muni.cz\>

  ## COPYRIGHT

Copyright (C) 1994-1996  Jan "Yenya" Kasprzak \<kas@muni.cz\>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
