10

I was working on my project in Windows using Eclipse (and I didn't check that my encoding was CP-1251). Now am going to work with my project in Linux with Eclipse too, but with UTF8 encoding, so all my comments are now non readable.

Can I just reconvert them into UTF using Eclipse?

Chandrayya G K
  • 8,719
  • 5
  • 40
  • 68
bukka.wh
  • 913
  • 2
  • 16
  • 29

3 Answers3

15

You can set up the encoding used by eclipse in the Preferences section

Window -> Preferences -> General -> Workspace -> Text file encoding

You can also override it for a single project only if that is the only project you are having trouble with.

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Arnaud Potier
  • 1,750
  • 16
  • 28
  • 2
    Yes, but I want to change all my project encoding to UTF-8. And in this case my comments (on Russian) will be represented as unreadable symbols. I need to decode my CP1251 text to utf-8 with my comments. – bukka.wh Jan 21 '14 at 16:07
  • 2
    In this case you need to convert the whole file. And so do it one by one (but you can write a little script easily) http://stackoverflow.com/questions/64860/best-way-to-convert-text-files-between-character-sets – Arnaud Potier Jan 21 '14 at 16:48
0

There is a plugin for Eclipse "Autodetect Encoding" - you can detect/convert the encoding in files. It can be found in the Help->Marketplace...

I just started testing, but it works so far.

Hint: sometimes you need to change the detector to ICU4j

And even if the convert does not work in a current document (because of detection) you can do this: CTRL+C on one enconding switch to another and CTRL+V it will paste correct then save.

Bartek B.
  • 119
  • 1
  • 7
0

In my case, I wanted to change the encoding for some .properties files.

I guess it works for other file types as well.

What I did and worked perfectly is:

Go to Window --> Preferenes --> General --> Content Types --> (Expand) Text--> Find Java Properties File --> Changed Default Encoding to UTF-8 --> Clicked Update

Here is a picture:

preview

I do not know if this option exists in previous versions, but my version is 2020 - 06.

George Z.
  • 6,643
  • 4
  • 27
  • 47