Character set conversion on Linux / Mac OS


The easiest way to convert characters set on Linux or Mac OS systems is to use iconv program. The iconv program converts text from one encoding to another encoding.

The iconv program has a quite big set of supported encodings. To get a list of supported encodings just run:

iconv --list

Example:

...
UTF-8 UTF8
UTF-16
UTF-16BE
UTF-16LE
UTF-32
UTF-32BE
UTF-32LE
...
CP1250 MS-EE WINDOWS-1250
CP1251 MS-CYRL WINDOWS-1251
CP1252 MS-ANSI WINDOWS-1252
CP1253 MS-GREEK WINDOWS-1253
CP1254 MS-TURK WINDOWS-1254
...

The conversion itself is straightforward. Let’s say you want to convert my-document.txt from ISO-8859-1 to UTF-8; you run the command as follows:

iconv -f ISO-8859-1 -t UTF-8 my-document.txt > my-document-UTF8.txt

Tags:

#encoding#linux#macos#utf-8


You may also be interested in: