Intellij idea 12 encoding cannot map characters

Source: Internet
Author: User

Error message in intellij idea: Java: syntax error on token "invalid character", delete this token

Error message in intellij idea: "invalid character: \ 65279"

An error occurred while importing a project in myeclipse to intellij idea.

 

Method 1 provided in this article is successfully used in intellij idea 10, but failed to use in intellij idea 12. In intellij idea 12, you have to use the more troublesome method 2 to succeed.

 

I. Problem description:

Import the project code created in eclipse to intellij idea and find Chinese garbled characters. Use the tool to convert the source file encoding to "UTF-8", the display is normal, but after modifying the file, "invalid character: \ 65279" appears during compilation ".

Ii. cause:

Intellij idea automatically adds a UTF-8 file signature to a file that is set to "UTF-8" encoded when it is modified and saved after modification, that is, BOM (view the file in hexadecimal form, the first part of the file is "Ef bb bf ").

Iii. solution:

(1) Use the eclipse compiler for compilation. The setting method in intellij idea 10.0 is settings (CTRL + ALT + S) -> Project setting-> compiler-> JAVA complier-> Use complier select eclipse and click OK

(2) use Notepad ++ to remove BOM [IN intellij idea 12, successful]

Specific Method: first set to UTF-8 without ROM encoding, and then open the file, save this file, overwrite the original file.

Setup method: format-> encoded as UTF-8 without ROM.

 

When using intellij idea 12, you can first try the first method. If it fails, then use the second method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.