11

I have some UTF-8 HTML templates in my Eclipse project and Eclipse keeps treating them as if they had a different encoding. It says the encoding is "determined from content". I want to force the correct encoding.

I can force it for a single file but setting an encoding for the parent folder won't affect the files in it because instead of the "inherit" option in the property sheet there's the "determined from content" thing in it's place.

Is it possible to set the encoding for all files in a Project at once?

markus
  • 40,136
  • 23
  • 97
  • 142
Tomas Andrle
  • 13,132
  • 15
  • 75
  • 92

3 Answers3

8

I've just solved this problem (eclipse 3.5.2)

Two steps required:

  1. Change text file encoding on the folder property page(.setting/org.eclipse.core.resources.prefs file has been created in my project)
  2. Change default encoding on *.html file content type on the Preference page General/Content Types
Andreas Louv
  • 46,145
  • 13
  • 104
  • 123
arty
  • 96
  • 1
  • 2
1

This was caused by a development version of Eclipse. In the latest official release (3.5) it is fixed.

Tomas Andrle
  • 13,132
  • 15
  • 75
  • 92
  • I'm afraid this isn't true (for me anyway). I have the exact same problem and I'm using Helios 3.6.1. Also forcing the JSP page to UTF8 seems to mangle it. – Dark Star1 Feb 05 '11 at 04:52
  • I still had this in Kepler 4.3, too. But following arty's step advice of setting the default encoding of *.html files under Content Types fixed it. – Henrik Heimbuerger Sep 08 '13 at 20:16
1

I've only seen "determined from content" for XML files. In that case it's the only correct setting, because XML files have their encoding defined in their header, so forcing anything else would be a grave mistake.

If you still want to do it, you could try to view the file .settings/org.eclipse.core.resources.prefs in your project (that file may or may not exist dependin on wether you've manually set any encoding in the project or not).

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
  • What about XML/HTML files where the encoding in the header is a variable looked up at runtime? What about includes where you can't specify the encoding in the file? "Determined from content" isn't the correct setting, nor is it a grave mistake to use another option. In these use cases, not being able to tell it to use the project-wide encoding (without having to add every single file to org.eclipse.core.resources.prefs) is a bug. – DaveS Nov 23 '11 at 17:55
  • An XML file wher the encoding in the header is a variable looed up at runtime *is not a valid XML file*. It might be a template for an XML file, but it is not in itself one. – Joachim Sauer Nov 24 '11 at 06:20
  • Exactly, it's a template, which is what TomA was (and what I am currently) having an issue with. But because the template file ends in .html (framework's choice), Eclipse tries its simple algorithm: 1) Look for content-type declaration in content of file. 2) Use system encoding. Why isn't there an intermediary step, 1.5) Use the encoding set at the project level. Or why can't we use wildcards in org.eclipse.cor.resources.prefs to say something like /folder/*.html? – DaveS Nov 24 '11 at 20:21