Eclipse encoding format (Chinese garbled)

https://jingyan.baidu.com/article/2009576193ee38cb0721b416.html

Modify workspace default encoding

  1. 1

    Enter Eclipse, import a project project, if the encoding of the project file is inconsistent with your tool encoding, it will cause garbled characters. Such as:

    Eclipse modify the encoding format
  2. 2

    If you want to enable the plug-in development application to have better internationalization support and to support Chinese output to the greatest extent, it is best to use UTF-8 encoding for Java files.

    Modify the default encoding

    On the menu navigation bar Window-->Preferences to open the "Preferences" dialog, the left navigation tree, navigate to General-->Workspace

     

    Eclipse modify the encoding format
  3. 3

    Windows 7 platform defaults to GBK, Simplified Chinese operating system Windows XP, Windows 2000 Simplified Chinese default encoding is GB18030, Linux platform defaults to UTF-8

    Then the project code created in this workspace is GBK, and the java file created in the project is also GBK.

    You can see that the default is GBK encoding format, we modify it to UTF-8 encoding format or the encoding format you need  

    Click Apply and click OK.

    Eclipse modify the encoding format
    END

Modify the encoding of the file

  1. 1

    Sometimes we import the project file, but it is not imported into our workspace, it is just a reference. If there is a coding problem at this time, we can modify the coding of the file to view it.

    Right-click on the Eclipse project file, select Properties, and select Modify the encoding format in Resource

    Eclipse modify the encoding format
    END

Modify the encoding of a file type

  1. 1

    Sometimes we need certain types of files, such as: *.jsp, *.java, etc.

    Navigation bar window-->preferences

    Open the "Preferences" dialog, navigate the tree on the left, navigate to Genera-->Content Types

    Eclipse modify the encoding format
  2. 2

    Find the type of file to be modified on the right, I take *.java as an example

    In the Default encoding below, enter UTF-8->Update->OK in the input box 

    Eclipse modify the encoding format
    END

Modify the encoding of a single file (for projects imported from outside, when modifying the workspace is invalid, modify the encoding of a single file to utf-8/GBK, which is valid)

  1. 1

    Right click on the file in the package explorer -> properties, change the text file encoding format to UTF-8 

    Eclipse modify the encoding format

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324482528&siteId=291194637