72

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?

0

1 Answer 1

122

Use iconv:

iconv -f iso-8859-1 -t utf-8 < file > file.new
8
  • 7
    @Arjan Note that Google points to this answer first..
    – tomdemuyt
    Jun 18, 2011 at 19:18
  • 2
    I did this.. now that file was completly emptied....... and I don't have any backup of it.. great..........
    – OZZIE
    Nov 3, 2018 at 14:33
  • 1
    @OZZIE then I am afraid you did it wrong Feb 11, 2019 at 1:06
  • 2
    @Greenonline: Both < and > are intentional – they redirect input from file and output into file.new. The input redirection is optional since iconv could read its input directly, but I wanted it to be present for consistency. Jul 1, 2022 at 7:50
  • 1
    take note that file.new MUST NOT BE the same as file, otherwise the result will indeed be an empty file
    – René Roth
    Sep 18, 2023 at 13:49

Not the answer you're looking for? Browse other questions tagged .