5

I had to change the Eclipse Indigo encoding to UTF-8. Now all the spécial characters as éàçè are replaced with �.

I can do a search and replace but I wonder if there is better solution.

Thanks

Momo
  • 2,471
  • 5
  • 31
  • 52
  • You'll need project-specific encoding, then. – Marko Topolnik Jul 17 '12 at 14:26
  • 1
    Check out http://stackoverflow.com/questions/64860/best-way-to-convert-text-files-between-character-sets as this seems to be what you want – Daniel Leschkowski Jul 17 '12 at 14:28
  • 1
    @MarcoTopolnik he has changed the encoding, now he has to deal with the broken chars. If he did want another encoding i assume he would have left it as it was before ;) – Daniel Leschkowski Jul 17 '12 at 14:30
  • 1
    Changing the encoding in Eclipse doesn't change your existing files : it only changes the way Eclipse reads them. What you need is to convert your old files to UTF-8 as well as configuring Eclipse. There are some tools to do that and you may write a small java program too. – Denys Séguret Jul 17 '12 at 14:42
  • @dystroy that's true, because when I open a class with NotePad++, the characters are displayed properly. – Momo Jul 17 '12 at 14:48

3 Answers3

7

Changing the encoding in Eclipse doesn't change your existing files : it only changes the way Eclipse reads them.

What you need is to convert your old files to UTF-8 as well as configuring Eclipse.

There are some tools to do that and you may write a small java program too.

If you want to use an existing tool, here's the first I found : http://www.marblesoftware.com/Marble_Software/Charco.html (you could find a better one for your (unspecified) OS.

If you want to write a tool yourself (about 20 LOC), the thing to know is that you must :

Here's the core of the operation :

  reader = new BufferedReader(new InputStreamReader(new FileInputStream(...), "you have to know it"));
  writer = new OutputStreamWriter(new FileOutputStream(...), "UTF-8"); 
  String line;
  while ((line=reader.readLine())!=null) {
     writer.write(line);
  }
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
2

I recommend notepad++ for conversion. This is an editor which has some very useful/powerful view and conversion tools to troubleshoot charsets. Also some more "swiss-knife"-like functions (file comparison, advanced search and replace and many more...)

notepad++

0

Just only need alt + enter then chooses resource UTF-8

angel
  • 41
  • 1
  • 6
  • 1
    Even neon 3 can't do the transfer automatically. First change the resource to let's say ISO-8859-1 or depending whatever encoding the file actually is, cut the text to clipboard and save the file empty. Don't forget to close the editor. Then do the alt + enter trick and change the file encoding, open the file and paste the content back. – Tuomas Kiviaho Jun 30 '17 at 07:22