Task: convert files from one encoding (for example, KOI8-R) to another (for example, UTF-8). This needs to be done from Unix (i.e., FreeBSD, Linux Debian, CentOS, Ubuntu, RedHat).
For this we use the iconv utility.
1) Installing
On Debian/Ubuntu and CentOS/RedHat this utility comes out of the box — it isn't even listed in the repositories.
On FreeBSD it's also installed by default, but if it happens to be missing:
$ cd /usr/ports/converters/iconv
$ sudo make install clean
2) Using it
The usage is very simple. Here's an example:
$ iconv -f KOI8-R -t UTF8 myfile1.txt > myfile2.txt
here the parameters are:
- -f : source encoding (to convert from)
- -t : target encoding (to convert to)
- myfile1.txt : source file
- myfile2.txt : target file
As you can see, it's all simple.
Comments