How to change default text file encoding in Eclipse?

Eclipse

Eclipse Problem Overview


Whenever I add a new html file (or other text file) to the project its encoding is set to Cp1250. I am not sure why, I guess this is probably because my default language in Windows is Polish and I don't want to change it. Anyway, Eclipse says that Cp1250 is a 'default' encoding and I have to manually change it to UTF-8 each time I add anything.

So where can I change the default encoding to UTF-8? I've set the encoding by right-clicking on whole project but it didn't help. I can't find anything in options. It's so annoying...

I'm using 'Helios' release of the eclipse and use it with pydev if that matters.

Eclipse Solutions


Solution 1 - Eclipse

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

Solution 2 - Eclipse

Nanda's answer wasn't enough in my setup. What I needed to do is:

  • Window > Preferences > General > Content Types
  • Select Text > HTML in the tree
  • Select all file associations, particularly .html
  • Input "UTF-8" in the text-field "default encoding"

Solution 3 - Eclipse

For eclipse Mars:

Change Workspace Encoding:

Change workspace encoding

Check a file Encoding: Image check a file encoding

Solution 4 - Eclipse

Preferences >> General >> Editors >> Text editors >> Spelling: Enconding

P.S.: Eclipse Indigo and Juno.

Solution 5 - Eclipse

I was having the same problem when I received a html to put inside my project and rename it to .jsp. To solve the problem, I needed to what people above already said, that is, to change text encoding in Eclipse Preferences. However, before renaming the files to .jsp, it was necessary to include the following line in the beginning of each .html file:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

I believe this forced Eclipse to understand that it was necessary to change file encoding when I tried to rename .html to .jsp.

Solution 6 - Eclipse

If you need to edit files of same type with more encodings in different folders and projects (e.g. one project is in UTF-8 and other in Windows-12xx), go to Window > Preferences > General > Content Types > Text > and select each type with multiple encodings.

For each type delete content of the Default encoding and click Update.

This way Eclipse will not "autodetect" encoding and will use encoding set for project or folder.

Solution 7 - Eclipse

What worked for me in Eclipse Mars was to go to Window > Preferences > Web > HTML Files, and in the right panel in Encoding select ISO 10646/Unicode(UTF-8), Apply and OK, then and only then my .html files were created with .

Solution 8 - Eclipse

To change the default encoding used for all workspaces you can do the following:

Create a defaults.ini file in the Eclipse configuration folder. For example, if Eclipse is installed in C:/Eclipse create C:/Eclipse/configuration/defaults.ini. The file should contain:

org.eclipse.core.resources/encoding=UTF-8

If you want to set the line terminator to UNIX values you can also add:

org.eclipse.core.runtime/line.separator=\n

In eclipse.ini in the Eclipse install folder (e.g., C:/Eclipse) add the following lines:

-plugincustomization 
D:/Java/Eclipse/configuration/defaults.ini

You might need to play around with where you put it. Inserting it before the "-product" option seemed to work.

Solution 9 - Eclipse

Window>Preferences>Web>JSP files

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPawelRomanView Question on Stackoverflow
Solution 1 - EclipsenandaView Answer on Stackoverflow
Solution 2 - EclipseBiAiBView Answer on Stackoverflow
Solution 3 - Eclipsevanduc1102View Answer on Stackoverflow
Solution 4 - EclipseMerphysView Answer on Stackoverflow
Solution 5 - EclipseFelipe MartinsView Answer on Stackoverflow
Solution 6 - EclipseRadek PechView Answer on Stackoverflow
Solution 7 - EclipseAlcidesView Answer on Stackoverflow
Solution 8 - EclipserghomeView Answer on Stackoverflow
Solution 9 - EclipsemouezaView Answer on Stackoverflow