Converting the encoding of a text file (Mac OS X)

52

24

Possible Duplicate:
How can I convert multiple files to UTF-8 encoding using *nix command line tools?

Okay, now that I can detect the encoding, I know that my encoding is using charset=iso-8859-1 instead of utf. How can I convert this?

Casebash

Posted 2010-06-13T08:55:49.513

Reputation: 5 677

Question was closed 2010-06-13T16:12:19.740

Answers

96

iconv -f iso-8859-1 -t utf-8 < file > file.new

user1686

Posted 2010-06-13T08:55:49.513

Reputation: 283 655

4@Arjan: Because I wanted to post a straightforward answer, without hiding it in for loops and "bash magic"? – user1686 – 2010-06-13T12:32:42.623

Ok, that might make sense indeed (though such straightforward answers are found in the other questions too). No need for the < by the way. – Arjan – 2010-06-13T12:44:22.957

I did this.. now that file was completly emptied....... and I don't have any backup of it.. great.......... – OZZIE – 2018-11-03T14:33:26.427

1@OZZIE then I am afraid you did it wrong – Matt Sephton – 2019-02-11T01:06:54.580

6@Arjan Note that Google points to this answer first.. – tomdemuyt – 2011-06-18T19:18:12.940