The open-source eclipse file transcoding plug-in can change the project file encoding without affecting Chinese characters.

Source: Internet
Author: User

Original Author address:
Http://www.blogjava.net/lifesting/archive/2008/04/11/192250.html, thank you!

 

Problem description:
Our project development uses UTF-8 encoding in a unified manner, but a product from the R & D department needs to be integrated yesterday. They use GBK encoding. If we forcibly set the file to UTF-8, it will not work, all Chinese characters are messy. In JSP, you cannot use Ctrl + H for search replacement, and Chinese characters cannot be displayed.

 

Old solution:
Set the project files to UTF-8 encoding, open one file with ultraedit, paste it into eclipse, and save it. This method is the most stupid and tiring, but you can only do physical work without any other good methods. After all, results are the most important.

 

This plug-in process is found:
I told developers that we have to change the encoding at a very high cost, and our project will eventually be released on the AIX machine, so please try to be consistent with us, after all, R & D helps us implement our projects. Later, I talked to the manager QQ. The manager meant that we 'd better provide solutions and do not make others too painful (the leaders looked at the problem more comprehensively, ^_^ ). Suddenly, I used to search with Baidu. This time I used Google, and the hit rate for searching materials may be higher. As a result, I was lucky enough to find a solution. Thanks again.

 

Note: I want to return an email after reading the article. Please refer to this article. The colleague next to me immediately reminded me to test it first. Otherwise, it would not be very interesting if I sent it again. (In this case, it should be noted that if the test is not complex and the test conditions are met, it is best to provide a solution to others and try it on your own)

 

Solution Process (plug-in usage, post ):

 

Step1.

Copy com. lifesting. tool. encoding_1.0.0.jar to the eclipse/Plugins directory and restart eclipse.

Step2.

Select a project, right-click Properties, and click convert setting to set transcoding rules, as shown in:

(Figure 2 configure project transcoding Rules)
This table has four columns:File suffix
,Current file encoding
,Converted Encoding
,Yes
No conversion file content,

If you want to convert the file content, it corresponds to the second case mentioned above. If you do not convert the file content, it corresponds to the first case. Than 2 of the transcoding rules is the JSP file of the project, no matter what the original encoding, unified into UTF-8 encoding, and at the same time to convert the file
Content
. You can click Add/Remove on the right to add or delete rules. Click Apply to save the settings.

Step 3
. Transcoding
On the project with transcoding rules set, right-click the project, select several folders or several files (of course one can also be), and then click lifesting tools-> set
Encoding. The plugin completes transcoding. If you select a project, the entire project will be converted; if you select a folder, all files under the folder that meet the rules will be converted; if you select a file
To convert files.

(Figure 3 transcoding)
In addition to this method, we can also use the file search function of eclipse to transcode the searched files, such:

(Figure 4 transcoding in search view)
As shown in, we found the JSP file of the entire workspace, and then click the green e small icon, the plug-in will transcode all the files that meet the results, the conversion rules of each file depend on its items
Set the destination transcoding rule.

 

Related Article

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.