iconv unicode unknown input format iconv unicode unknown input format unix unix

iconv unicode unknown input format


Converting from UTF-8 to ISO-8859-1 only works if your UTF-8 text only has characters that can be represented in ISO-8859-1. If this is not the case, you should specify what needs to happen to these characters, either ignoring (//IGNORE) or approximating (//TRANSLIT) them. Try one of these two:

iconv -f UTF-8 -t ISO-8859-1//IGNORE --output=outfile.csv inputfile.csviconv -f UTF-8 -t ISO-8859-1//TRANSLIT --output=outfile.csv inputfile.csv

In most cases, I guess approximation is the best solution, mapping e.g. accented characters to their unaccented counterparts, the euro sign to EUR, etc...


The problem was that Windows could not interpret the file as UTF-8 on itself. it reads it as asci and then ä becomes a 2 character interpretation ä (ascii 195 164)

trying to convert it, I found a solution that works for me:

iconv -f UTF-8 -t WINDOWS-1252//TRANSLIT --output=outfile.csv inputfile.csv

now I can view the special chars correctly in editors

For SQLServer compability, converting UTF-8 to UTF-16 will work even better ... just the filesize grows quite a bit


If you are not sure about the file type you dealing with then you can find it as follows,

file file_name

The above command will give you the file format. Then iconv can be used accordingly.For example if the file format is UTF-16 and you want to convert it to UTF-8 then following can be used.

iconv -f UTF-16 -t UTF-8 file_name >output_file_name

Hope this gives add on insight to what you are looking for.