February 21, 2011

iconv and sed help



I have a file which is a UTF-8 file type which i need to convert into ISO-8859-1 file type.

Now the UTF-8 file type contains characters like å/ä/ö and i dont want these characters.

So, i apply the sed command.

$ sed "s/å/aa/g; s/ä/aaa/g; s/ö/ooo/g" utf8.txt > output.txt

Now when i view this file, there are no such characters like å/ä/ö


i use iconv command to covert that UTF-8 (output.txt) file type into ISO-8859-1 file type

$ iconv -c -f UTF-8 -t ISO-8859-1 < output.txt > newfile


when i view the file type using file command it tells that its an ASCII file type not the ISO-8859-1

$ file newfile
newfile: ASCII text, with CRLF line terminators

I don't understand what went wrong. I have also attached that UTF-8 file with this post.

Please help.


Click Here!