Specify UTF-8 Encoding
You can specify character encoding for objects in Eclipse.
Overview
You can specify character encoding for the following objects in Eclipse:
Files | You can specify the character encoding for individual files or for all files of a given content type. |
Projects | Specifying character encoding for a project sets the default for all new files created in that project. You can set character encoding for projects individually, or for all projects created in an Eclipse workspace. |
Workspaces | Specifying character encoding for a workspace sets the default for all new projects created in that workspace. |
The following sections summarize the procedures you can use to specify UTF-8 character encoding in Eclipse. Refer to your Eclipse user documentation for additional information.
Set encoding for a file
- In the Package Explorer, right-click the file whose encoding you want to set and the choose Properties from the shortcut menu.
- On the Resource page, in the Text file encoding group, select Other and then choose UTF-8 from the list.
- Click OK to save the settings and close the Properties dialog box.
Tip: You can also set the character encoding based on a file’s content type. See Other preferences for character encoding for more information.
Set encoding for a project
Setting the character encoding for a project sets the encoding for any new files created in that project.
To set the character encoding for a project:
- In the Package Explorer, right-click the project whose encoding you want to set and then choose Properties from the shortcut menu.
- On the Resource page, in the Text file encoding group, select Other and then choose UTF-8 from the list.
- Click OK to save the settings and close the Properties dialog box.
Set encoding for a workspace
Setting character encoding for a workspace sets the default for all new projects created in that workspace.
To set character encoding for a workspace:
- From the main menu, select
.
The Preferences dialog box appears.
- Navigate to display the Workspace page.
- In the Text file encoding group, select Other and then choose UTF-8 from the list.
-
Click OK to save the settings and close the Properties dialog box.
Other preferences for character encoding
To locate all the places where you can specify preferences for character encoding, type “encoding” in the Preference dialog box Filter field. As you type, titles of the preference pages containing “encoding” are displayed in the Preferences dialog box left pane:
Navigate the preference pages for the plug-ins you have installed and review, and optionally set character encoding on those pages.
For example, to set character encoding based on a file’s content type:
- From the main menu, select Window > Preferences. The Preferences dialog box opens.
- Navigate General to display the Content Types page.
- Scroll through the Content types field, review the corresponding file associations, and set the value in the Default encoding field as needed.
- Click the OK button to save the settings and close the Preferences dialog box.