Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368817

Summary: Projects should always specify encoding
Product: [Eclipse Project] Platform Reporter: Olaf Titz <olaf.titz>
Component: ResourcesAssignee: Platform-Resources-Inbox <platform-resources-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: minor    
Priority: P3 CC: daniel_megert, Szymon.Brandys
Version: 4.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Olaf Titz CLA 2012-01-17 07:03:26 EST
Build Identifier: Version: 3.6.1 Build id: M20100909-0800

I'm working with workspaces consisting of (Java) projects from different teams from different original VCS repositories, each of these teams have (historically) different default encodings for their workspaces. Now some parts of my workspace are CP1252, some are UTF-8, and not all of them specify their project encoding in the project (i.e. in .settings/org.eclipse.core.resources.prefs). This makes it very likely that developers get and/or produce corrupted text files.

As is evident in the discussion on bug 108668, there is no single default character encoding which fits all purposes. It makes little sense to default encoding on the platform, as is currently the case, as soon as projects are shared between users. Strictly speaking, the contents of text files in a VCS checked in by a user only relying on workspace default encoding are undefined.

To fix this, it should be mandatory to specify an encoding per project. This can still default to the workspace default, which itself defaults to the platform encoding if not set by the user, but a .settings/org.eclipse.core.resources.prefs file with the encoding/<project>=... line should always be written when creating a project.
This way you can import an arbitrary set of projects into an arbitrary workspace and get the encoding right, always.

(Of course this can be done manually but the platform should do its best to enforce consistency.)

Reproducible: Always
Comment 1 Szymon Brandys CLA 2012-01-17 08:11:16 EST
(In reply to comment #0)
> To fix this, it should be mandatory to specify an encoding per project. This
> can still default to the workspace default, which itself defaults to the
> platform encoding if not set by the user, but a
> .settings/org.eclipse.core.resources.prefs file with the encoding/<project>=...
> line should always be written when creating a project.

I don't see a good reason to obligatorily specify the project encoding. If your team needs it, you can always write a simple plug-in for the team that sets the encoding on project creation and validates that all projects in your workspace have it set too.
Comment 2 Dani Megert CLA 2015-10-09 12:04:49 EDT
.

*** This bug has been marked as a duplicate of bug 479450 ***