How to change the encoding of multiple files from ISO-8859-1 to UTF-8?

0

I have a project (in java) with more than 100 files, some of them are in other ISO in UTF8.

How to change the encoding of all ISO files to UTF-8 without losing the special characters?

    
asked by anonymous 02.04.2014 / 14:06

2 answers

2

If you are using Eclipse :

  • Open Eclipse with your project;
  • In the " Project Explorer " tab, right-click and select "Properties" ;
  • In the left menu, choose " Resource " and right, under " Text File Encoding " choose UTF-8;
  • Okay at all;
  • If you are on NetBeans :

  • Open NetBean with your project;
  • Right click and select " Properties ";
  • In the left menu, select " Source Codes " and right, right at the bottom, change the " Encoding " to UTF-8; >

    As you said that your project has more than 100 files in encoding other than UTF-8, and you will change them, it is very likely that a lot of special characters will break (even if you do not want to). For example: "á" can become " ". What's more, if you compile your software, you might get unmappable character .

    Take a test in NetBeans, I did some testing here and did not break special characters, unlike Eclipse.

        
  • 02.04.2014 / 18:35
    1

    It's good to set up your editor to use the correct encoding later, but initially it's much better to convert the files automatically.

    If you're on any Unix, just use the recode:

    $ recode utf8 *.java
    

    To process recursively:

    $ find . -name "*.java" -exec recode utf8 {} \;
    

    The recode is very flexible, you can do a lot more things. Credits for this response .

        
    02.04.2014 / 18:52