convert encoding with iconv
August 24th, 2007
Most Unix-like systems are equipped with a powerful program called iconv. This program enables you to convert any file from virtually any encoding to another. The syntax of the command is as follows:
For example, this command
will convert the contents of the input.txt file from windows-1253 encoding to utf-8. The output will be sent to standard output. If you want to write the converted output to a file you should use redirection:
If the input-file parameter is omitted, standard input will be used.
To get a list with all the encodings supported in your system by iconv, run this command:
If you are interested in iconv but you are a Windows user, the good news is that iconv is included in GnuWin32.
iconv -f from-encoding -t to-encoding input-fileFor example, this command
iconv -f WINDOWS-1253 -t UTF-8 input.txtwill convert the contents of the input.txt file from windows-1253 encoding to utf-8. The output will be sent to standard output. If you want to write the converted output to a file you should use redirection:
iconv -f WINDOWS-1253 -t UTF-8 input.txt > output.txtIf the input-file parameter is omitted, standard input will be used.
To get a list with all the encodings supported in your system by iconv, run this command:
iconv -lIf you are interested in iconv but you are a Windows user, the good news is that iconv is included in GnuWin32.