2

During my CS studies, we have a good bit of group assignments. We program in Java using Eclipse. We (or atleast i try to get them to) share code using Mercurial and BitBucket. I'm running Mac OSX 10.7 and the others are running Windows 7. We often have problems with the encoding when we share code. Danish characters such as æ, ø and å is often a mess.

What settings should we run across our eclipse setups to ensure that the encoding will be the same (and what encoding would be preferred?) On Windows, Eclipse defaults to Cp1252 and on MacOS it defaults to MacRoman. I've been trying to get everyone to use UTF-8, but code they previously wrote (in Cp1252) wont show correctly, so they are forced to switch around a lot, which usually ends up in them defaulting back to Cp1252 and forgetting about it when they submit code to a shared repository.

leflings
  • 646
  • 3
  • 17

3 Answers3

6

For me it works to use the standard encoding (Cp1252) in Eclipse on Windows and to tell Eclipse on Mac to use the encoding ISO-8859-1. On Mac I configured this for my whole workspace in the settings (under General --> Workspace).

skrusche
  • 133
  • 1
  • 8
  • That is not a good idea. I followed this suggestion some years ago and we got lots of issues over the years: macOS user forgetting to configure encoding when installing a new Eclipse and committing UTF8 unintentionally, Windows user committing Cp1252 characters that are not compatible with ISO-8859-1, to name a few. – qxlab May 09 '20 at 17:53
0

Speaking from experience, I believe the best solution is for everybody to use UTF-8, that can represent any Unicode character.

The workaround CP1252 & ISO-8859-1 is not perfect, some characters are not compatible between them. Moreover, most IDEs default to UTF-8, if someone must have the trouble of changing Eclipse encoding settings, I believe it should be Windows users.

So after much headache using CP1252 & ISO-8859-1, I decided to change all my files to UTF-8. In case someone is interested, you can do that on Unix with a command like this, that will change all files in the current directory and its subdirectories:

find . -name "*.java" -exec sh -c "iconv -f ISO-8859-1 -t UTF-8 {} > {}.utf8"  \; -exec mv "{}".utf8 "{}" \;

Since you are informing the original encoding, iconv will be able to convert without messing with accents and special characters.

Then ask everybody to create a new workspace, configure all encoding configuration on Eclipse to UTF-8 (Windows users) and import the project again.

qxlab
  • 1,506
  • 4
  • 20
  • 48
0

Encode old 1250 texts into UTF8 by hand and use only these versions

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110