Convert Text Between Different Encodings Using iconv

If you want to convert files from one encoding to another you want to use the tool iconv:

iconv -f WINDOWS-1252 -t UTF-8 about.txt  > about.utf.txt

The above command converts the about.txt input file from the old West-European encoding ISO-8859-1 to UTF-8 and saves the result to about.utf.txt.

The command iconv --list lists the supported encodings. Included are:

  • WINDOWS-1252
  • LATIN1 !
  • ISO_8859-1 !
  • ISO_8859-15 !
  • UNICODE
  • UNICODEBIG
  • UNICODELITTLE
  • US-ASCII
  • US
  • UTF-7
  • UTF-8 !
  • UTF-16
  • UTF-16BE
  • UTF-16LE
  • UTF-32
  • UTF-32BE
  • UTF-32LE
  • UTF7
  • UTF8 !
  • UTF16
  • UTF16BE
  • UTF16LE
  • UTF32
  • UTF32BE
  • UTF32LE
  • and many more...

About the encodings in Germany: ISO 8859-1 (latin1) has fractions like ½, ISO 8859-15 has signs like €, Windows-1252 has both of them.
Source: ISO_8859-1 on German Wikipedia

resources

Comments