8.6.12 Convert a text file with recode
Following will convert text files between DOS, Mac, and Unix line ending
styles:
$ recode /cl../cr <dos.txt >mac.txt
$ recode /cr.. <mac.txt >unix.txt
$ recode ../cl <unix.txt >dos.txt
Free recode
converts files between various character sets and
surfaces with:
$ recode charset1/surface1..charset2/surface2 \
<input.txt >output.txt
Common character sets used are (see also Introduction to locales, Section
9.7.3) [
37] :
-
us — ASCII (7 bits)
-
l1 — ISO Latin-1 (ISO-8859-1, Western Europe, 8 bits)
-
EUCJP — EUC-JP for Japanese (Unix)
-
SJIS — Shift-JIS for Japanese (Microsoft)
-
ISO2022JP — Mail encoding for Japanese (7 bits)
-
u2 — UCS-2 (Universal Character Set, 2 bytes)
-
u8 — UTF-8 (Universal Transformation Format, 8 bits)
Common surfaces used are [
38] :
-
/cr — Carriage return as end of line (Mac text)
-
/cl — Carriage return line feed as end of line (DOS text)
-
/ — Line feed as end of line (Unix text)
-
/d1 — Human readable bytewise decimal dump
-
/x1 — Human readable bytewise hexidecimal dump
-
/64 — Base64 encoded text
-
/QP — Quoted-Printable encoded text
For more, see pertinent description in the info recode.
There are also more specialized conversion tools: