Eclipse Encoding MacRoman -> UTF8 - eclipse

I recently created a project, organized it and well... I used my Mac with Eclipse running. Somehow it stored everything in MacRoman. The project has to be UTF8.
Is there any easy way to handle the conversions?

You have some detailed explanation in this blog post by David HOLT for the WOLips/WOProject.
Check your default preferences:
In Eclipse, go to Preferences>General>Workspace and select UTF-8 as the Text File Encoding.
This should set the encoding for all the resources in your workspace. Any components you create from now on using the default encoding should all match.
Change the encoding for a resource (project, folder or file)
Right (or Control) click on the resource in the WO Package Explorer and select the Properties option at the bottom of the contextual menu.
Go to Resource>Text File Encoding.
You should see "Inherited from container (UTF-8)" if you've made the change above, otherwise it will be (MacRoman).
Select Other - UTF-8 and Apply to make the warning go away.

Related

Setting text file encoding per eclipse project

I wanted to know if its posible to set a different file encoding per each project I have on eclipse.
I know that I can have different workspaces and set a different encoding for each one, but id like to have all my projects on one, if posible...
Yes you can.
Open the Properties for the Project and select the 'Resource' tab. Set the 'Text file encoding' to what you want.
Make sure that all the files in the project have their Text file encoding set to 'Default (inherited from container)'
You can also set the defaults for everything in a Folder in the same way.
I think it's possible.
1.Select your project.
2.Right click and select Properties.
3.Select Resource menu and you can choose your file encoding.
This is not working with Eclipse Mars, for some file types, as eg JavaScript. For *.js files, the configuration "Determined from content type" is having precedence over the project's Resource configuration.
I've also tried to specify my JS directory encoding in .settings/org.eclipse.core.resources.pref, which is specific for the project, by defining
encoding//src/main/webapp/js=ISO-8859-1, but then again the workspace configuration is having precedence.
I have a development environment with two distinct projects, one in UTF-8 (newer) and anoter in ISO-8859-1 (legacy). I would like to easily switch between them.
One solution I've found was to create two workspaces. It worked, but it seems rather awkward as instructions to other developers. So it would be desirable to really have such configurations on a per-project basis.

Eclipse and netbeans for properties file in a project

I'm wondering if anyone has encountered this problem and how he solved it. I worked in a project where the IDE is not imposed to developpers (we can use Eclipse, Netbeans etc.).
When working with properties file (Java wait for an ISO-8859-1 encoding), eclipse handles them well, but in Netbeans, each national char (éàü etc.) are automatically escaped like this \uxxx. So eclipse users will get properties file with escaped characters, which is really annoying.
It is painful for i18n for instance.
Does anyone found a workaround for this ?
Edit
In Netbeans 8, it's possible to check an option for properties file that allow us to use project encoding. (See comments below).
That's a sane default behavior - properties file are read using ISO-8859-1 encoding by default (How to use UTF-8 in resource properties with ResourceBundle or find some other resources). I think that NetBeans editor lets you edit them using UTF-8 and converts the content on save. You can override this: select the file (for example in project tab), choose Properties from its context menu and make it use project encoding. NetBeans will not perform the conversion then.

Netbeans file cannot be safely opened

I get files from friend who don't use netbeans IDE, when i open file that contain special caracter like 'é','à',... it show me this popup message :
if i say yes it open the file and changes those caracters to '�' like or
Any idea how to open the file safely?
The letters you are mentioning seem to be French. You need to open the file, specifying the original encoding, then save the file as UTF-8
I recently encountered a very similar problem (I have some javascript files in Chinese which translated into similar non-human readable text upon re-opening the file in NetBeans).
My OS: Linux Mint (version 17, Cinnamon; Notepad++ not available and gedit did not solve the problem).
Netbeans Version: 8.0.1
However, I was blessed to have found the history feature! I was able to get a former version of my file restored and backed it up immediately.
To access a file's history simply click on the History button found on the left side of the tool bar between the tabs of open files at the top of the IDE and the actual source code. (You can also right click on the file name and selected History -> Show History). Then Double click on a *Timestamp representing a valid version of your file. Just below the table of Timestamps the old 'backup' file and the current 'corrupted' file should appear side-by-side. (You can preview several historical versions of the file until you find one that works best for you; of course, when choosing a file I suggest one which is still usable and has the most current Timestamp associated with it!) ). Right click again on the 'backup' version of your choice -> Revert from History. Click back on the Source button found right next to the History button.
Finally, to change the default encoding, I applied the fix suggested by Sebas and Danny here:
How to change file encoding in NetBeans?
Please note that the path to the netbeans.conf file is different (at least with version 8.0.1 on my Linux machine). The path on my machine was : ~/netbeans-8.0.1/etc/netbeans.conf.
This saved the day for me and I hope it helps someone else out there! Bonne chance.

How do I make an editor the default editor for all unknown files in Eclipse?

I regularly open files of different types in Eclipse. For many types, Eclipse uses the system editor by default. I don't want this to happen. I want Eclipse to use the built-in Text Editor for unknown file types. However all I can find are options to set the default editor for a certain file type, but not for all unknown ones. Is there an option to do this?
I don't think you can do this in one swoop, however:
Windows > Preferences > General > Editors > File Association.
If you don't have a LOT of unknown file types, just type *.junk, *.punk, *.clunck and add Text Editor as the default editor.
Sadly you can't use *.* here.
This issue with file associations is something that has always annoyed me with Eclipse. It is specially frustrating if you are trying to use Eclipse to edit files that don't have a file extension because then you can't even set a editor.
I searched over the Eclipse bug database and found my exact issue there. It was first reported in 2003 and up until now there is no solution for it. If you follow the long comment track over the years you will see that there is no way of setting a default editor for unknown file types. From what I gathered the problem boils down to eclipse not looking at the content of file to try to determine the type. Instead it fully depends on the file extension.
Some people have made suggestions for fixes but again nothing has come out of that. If you search the bug tracker DB you will find a lot more bugs created around this.
A clean solution to this is finally implemented in Eclipse.
On the Preferences > General > Editors > File Association page, you can now define an editor selection strategy for unassociated file types.
Source: https://www.eclipse.org/eclipse/news/4.6/platform.php#text-editor-selection-strategy
There is an Eclipse plugin that overrides the default behavior of the platform and opens text file of unknown type in the plain text editor of Eclipse instead in an external editor.
https://github.com/eclipselabs/default-text-editor

Change text encoding for multiple files at once in Eclipse

I have some UTF-8 HTML templates in my Eclipse project and Eclipse keeps treating them as if they had a different encoding. It says the encoding is "determined from content". I want to force the correct encoding.
I can force it for a single file but setting an encoding for the parent folder won't affect the files in it because instead of the "inherit" option in the property sheet there's the "determined from content" thing in it's place.
Is it possible to set the encoding for all files in a Project at once?
I've just solved this problem (eclipse 3.5.2)
Two steps required:
Change text file encoding on the folder property page(.setting/org.eclipse.core.resources.prefs file has been created in my project)
Change default encoding on *.html file content type on the Preference page General/Content Types
I've only seen "determined from content" for XML files. In that case it's the only correct setting, because XML files have their encoding defined in their header, so forcing anything else would be a grave mistake.
If you still want to do it, you could try to view the file .settings/org.eclipse.core.resources.prefs in your project (that file may or may not exist dependin on wether you've manually set any encoding in the project or not).
This was caused by a development version of Eclipse. In the latest official release (3.5) it is fixed.