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

5
  • You'll need project-specific encoding, then. Commented Jul 17, 2012 at 14:26
  • 1
    Check out stackoverflow.com/questions/64860/… as this seems to be what you want Commented Jul 17, 2012 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 ;) Commented Jul 17, 2012 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. Commented Jul 17, 2012 at 14:42
  • @dystroy that's true, because when I open a class with NotePad++, the characters are displayed properly. Commented Jul 17, 2012 at 14:48

3 Answers 3

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); } 
Sign up to request clarification or add additional context in comments.

Comments

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++

1 Comment

It's sad, that a large tool like eclipse does not have this functionality built in.
0

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

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.