This post shows how to view the opened file encoding in the eclipse source editor.And also How to change the default encoding to another character encoding.How to get default encoding?

How to view the Encoding of opened project or file?

You can check the encoding for a file or folder or a project resource.

  • Right-click on a folder or file resource on the left side Package Explorer
  • Select Properties or use shortcut key Alt + Enter
  • You can see Text File Encoding with default encoding of a given resource.
  • It shows UTF-8 as the default encoding.

Eclipse show default encoding

You can change the resource encoding to another encoding and save the changes. This change applies to only selected resources.

How to change default text file encoding in Eclipse?

In this, changing default encoding applies globally, which means all projects opened with eclipse.

  • Open Windows Menu > Preferences It opens Preferences Window

  • In General tab> Select Workspace

  • It Contains Text File Encoding panel section and contains following radio options

    • Default(cp1252)
    • Other dropdown contains ISO-8859-1,US-ASCII,UTF-16,UTF-16BE,UTF-16LE,UTF-8 values.
  • Select one of the options from the dropdown

  • Click on Apply and Close.

How to change encoding based on file extension types in eclipse?

Following are steps

  • Open Windows Menu > Preferences It opens Preferences Window
  • In General tab> Select Content Types
  • Select the file types in the Content Types section
  • Selected Java Source File and it shows File associations as *.java, you can still add a new file extension pattern.
  • Change the Default encoding textbox value to UTF-16
  • Click on the Update button
  • Finally, Click on Apply and Close

You can check options as per the below screenshot

Eclipse Change encoding for file extensions