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?

3 Answers 3

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

Comments

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).

3 Comments

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.
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.
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 <project>/folder/*.html?
1

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

2 Comments

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.